home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / diffutil.7 / diffutil / diffutils-2.7 / texinfo.tex < prev    next >
Encoding:
Text File  |  1994-09-20  |  139.7 KB  |  4,345 lines

  1. %% TeX macros to handle texinfo files
  2.  
  3. %   Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
  4.  
  5. %This texinfo.tex file is free software; you can redistribute it and/or
  6. %modify it under the terms of the GNU General Public License as
  7. %published by the Free Software Foundation; either version 2, or (at
  8. %your option) any later version.
  9.  
  10. %This texinfo.tex file is distributed in the hope that it will be
  11. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  12. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. %General Public License for more details.
  14.  
  15. %You should have received a copy of the GNU General Public License
  16. %along with this texinfo.tex file; see the file COPYING.  If not, write
  17. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  18. %USA.
  19.  
  20.  
  21. %In other words, you are welcome to use, share and improve this program.
  22. %You are forbidden to forbid anyone else to use, share and improve
  23. %what you give them.   Help stamp out software-hoarding!
  24.  
  25. % This automatically updates the version number based on RCS.
  26. \def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}}
  27. \deftexinfoversion$Revision: 2.134 $
  28. \message{Loading texinfo package [Version \texinfoversion]:}
  29.  
  30. % Print the version number if in a .fmt file.
  31. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  32.  
  33. % Save some parts of plain tex whose names we will redefine.
  34.  
  35. \let\ptextilde=\~
  36. \let\ptexlbrace=\{
  37. \let\ptexrbrace=\}
  38. \let\ptexdots=\dots
  39. \let\ptexdot=\.
  40. \let\ptexstar=\*
  41. \let\ptexend=\end
  42. \let\ptexbullet=\bullet
  43. \let\ptexb=\b
  44. \let\ptexc=\c
  45. \let\ptexi=\i
  46. \let\ptext=\t
  47. \let\ptexl=\l
  48. \let\ptexL=\L
  49.  
  50. % Be sure we're in horizontal mode when doing a tie, since we make space
  51. % equivalent to this in @example-like environments. Otherwise, a space
  52. % at the beginning of a line will start with \penalty -- and
  53. % since \penalty is valid in vertical mode, we'd end up putting the
  54. % penalty on the vertical list instead of in the new paragraph.
  55. {\catcode`@ = 11
  56.  \gdef\tie{\leavevmode\penalty\@M\ }
  57. }
  58. \let\~ = \tie                  % And make it available as @~.
  59.  
  60. \message{Basics,}
  61. \chardef\other=12
  62.  
  63. % If this character appears in an error message or help string, it
  64. % starts a new line in the output.
  65. \newlinechar = `^^J
  66.  
  67. % Set up fixed words for English.
  68. \ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi%
  69. \def\putwordInfo{Info}%
  70. \ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi%
  71. \ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi%
  72. \ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi%
  73. \ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi%
  74. \ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi%
  75. \ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi%
  76. \ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi%
  77. \ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi%
  78. \ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi%
  79.  
  80. % Ignore a token.
  81. %
  82. \def\gobble#1{}
  83.  
  84. \hyphenation{ap-pen-dix}
  85. \hyphenation{mini-buf-fer mini-buf-fers}
  86. \hyphenation{eshell}
  87.  
  88. % Margin to add to right of even pages, to left of odd pages.
  89. \newdimen \bindingoffset  \bindingoffset=0pt
  90. \newdimen \normaloffset   \normaloffset=\hoffset
  91. \newdimen\pagewidth \newdimen\pageheight
  92. \pagewidth=\hsize \pageheight=\vsize
  93.  
  94. % Sometimes it is convenient to have everything in the transcript file
  95. % and nothing on the terminal.  We don't just call \tracingall here,
  96. % since that produces some useless output on the terminal.
  97. %
  98. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  99. \def\loggingall{\tracingcommands2 \tracingstats2
  100.    \tracingpages1 \tracingoutput1 \tracinglostchars1
  101.    \tracingmacros2 \tracingparagraphs1 \tracingrestores1
  102.    \showboxbreadth\maxdimen\showboxdepth\maxdimen
  103. }%
  104.  
  105. %---------------------Begin change-----------------------
  106. %
  107. %%%% For @cropmarks command.
  108. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  109. %
  110. \newdimen\cornerlong \newdimen\cornerthick
  111. \newdimen \topandbottommargin
  112. \newdimen \outerhsize \newdimen \outervsize
  113. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  114. \outerhsize=7in
  115. %\outervsize=9.5in
  116. % Alternative @smallbook page size is 9.25in
  117. \outervsize=9.25in
  118. \topandbottommargin=.75in
  119. %
  120. %---------------------End change-----------------------
  121.  
  122. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  123. % does insertions itself, but you have to call it yourself.
  124. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  125. \def\onepageout#1{\hoffset=\normaloffset
  126. \ifodd\pageno  \advance\hoffset by \bindingoffset
  127. \else \advance\hoffset by -\bindingoffset\fi
  128. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  129. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  130. {\let\hsize=\pagewidth \makefootline}}}%
  131. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  132.  
  133. %%%% For @cropmarks command %%%%
  134.  
  135. % Here is a modification of the main output routine for Near East Publications
  136. % This provides right-angle cropmarks at all four corners.
  137. % The contents of the page are centerlined into the cropmarks,
  138. % and any desired binding offset is added as an \hskip on either
  139. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  140. %
  141. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  142. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  143.          \shipout
  144.          \vbox to \outervsize{\hsize=\outerhsize
  145.                  \vbox{\line{\ewtop\hfill\ewtop}}
  146.                  \nointerlineskip
  147.                  \line{\vbox{\moveleft\cornerthick\nstop}
  148.                        \hfill
  149.                        \vbox{\moveright\cornerthick\nstop}}
  150.                  \vskip \topandbottommargin
  151.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  152.             \vbox{
  153.             {\let\hsize=\pagewidth \makeheadline}
  154.             \pagebody{#1}
  155.             {\let\hsize=\pagewidth \makefootline}}
  156.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  157.          \vskip \topandbottommargin plus1fill minus1fill
  158.                  \boxmaxdepth\cornerthick
  159.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  160.                        \hfill
  161.                        \vbox{\moveright\cornerthick\nsbot}}
  162.                  \nointerlineskip
  163.                  \vbox{\line{\ewbot\hfill\ewbot}}
  164.     }}
  165.   \advancepageno
  166.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  167. %
  168. % Do @cropmarks to get crop marks
  169. \def\cropmarks{\let\onepageout=\croppageout }
  170.  
  171. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  172. {\catcode`\@ =11
  173. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  174. \dimen@=\dp#1 \unvbox#1
  175. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  176. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  177. }
  178.  
  179. %
  180. % Here are the rules for the cropmarks.  Note that they are
  181. % offset so that the space between them is truly \outerhsize or \outervsize
  182. % (P. A. MacKay, 12 November, 1986)
  183. %
  184. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  185. \def\nstop{\vbox
  186.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  187. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  188. \def\nsbot{\vbox
  189.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  190.  
  191. % Parse an argument, then pass it to #1.  The argument is the rest of
  192. % the input line (except we remove a trailing comment).  #1 should be a
  193. % macro which expects an ordinary undelimited TeX argument.
  194. %
  195. \def\parsearg#1{%
  196.   \let\next = #1%
  197.   \begingroup
  198.     \obeylines
  199.     \futurelet\temp\parseargx
  200. }
  201.  
  202. % If the next token is an obeyed space (from an @example environment or
  203. % the like), remove it and recurse.  Otherwise, we're done.
  204. \def\parseargx{%
  205.   % \obeyedspace is defined far below, after the definition of \sepspaces.
  206.   \ifx\obeyedspace\temp
  207.     \expandafter\parseargdiscardspace
  208.   \else
  209.     \expandafter\parseargline
  210.   \fi
  211. }
  212.  
  213. % Remove a single space (as the delimiter token to the macro call).
  214. {\obeyspaces %
  215.  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
  216.  
  217. {\obeylines %
  218.   \gdef\parseargline#1^^M{%
  219.     \endgroup % End of the group started in \parsearg.
  220.     %
  221.     % First remove any @c comment, then any @comment.
  222.     % Result of each macro is put in \toks0.
  223.     \argremovec #1\c\relax %
  224.     \expandafter\argremovecomment \the\toks0 \comment\relax %
  225.     %
  226.     % Call the caller's macro, saved as \next in \parsearg.
  227.     \expandafter\next\expandafter{\the\toks0}%
  228.   }%
  229. }
  230.  
  231. % Since all \c{,omment} does is throw away the argument, we can let TeX
  232. % do that for us.  The \relax here is matched by the \relax in the call
  233. % in \parseargline; it could be more or less anything, its purpose is
  234. % just to delimit the argument to the \c.
  235. \def\argremovec#1\c#2\relax{\toks0 = {#1}}
  236. \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
  237.  
  238. % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
  239. %    @end itemize  @c foo
  240. % will have two active spaces as part of the argument with the
  241. % `itemize'.  Here we remove all active spaces from #1, and assign the
  242. % result to \toks0.
  243. %
  244. % This loses if there are any *other* active characters besides spaces
  245. % in the argument -- _ ^ +, for example -- since they get expanded.
  246. % Fortunately, Texinfo does not define any such commands.  (If it ever
  247. % does, the catcode of the characters in questionwill have to be changed
  248. % here.)  But this means we cannot call \removeactivespaces as part of
  249. % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
  250. % that \parsearg gets might well have any character at all in it.
  251. %
  252. \def\removeactivespaces#1{%
  253.   \begingroup
  254.     \ignoreactivespaces
  255.     \edef\temp{#1}%
  256.     \global\toks0 = \expandafter{\temp}%
  257.   \endgroup
  258. }
  259.  
  260. % Change the active space to expand to nothing.
  261. %
  262. \begingroup
  263.   \obeyspaces
  264.   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
  265. \endgroup
  266.  
  267.  
  268. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  269.  
  270. %% These are used to keep @begin/@end levels from running away
  271. %% Call \inENV within environments (after a \begingroup)
  272. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  273. \def\ENVcheck{%
  274. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  275. \endgroup\fi} % This is not perfect, but it should reduce lossage
  276.  
  277. % @begin foo  is the same as @foo, for now.
  278. \newhelp\EMsimple{Type <Return> to continue.}
  279.  
  280. \outer\def\begin{\parsearg\beginxxx}
  281.  
  282. \def\beginxxx #1{%
  283. \expandafter\ifx\csname #1\endcsname\relax
  284. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  285. \csname #1\endcsname\fi}
  286.  
  287. % @end foo executes the definition of \Efoo.
  288. %
  289. \def\end{\parsearg\endxxx}
  290. \def\endxxx #1{%
  291.   \removeactivespaces{#1}%
  292.   \edef\endthing{\the\toks0}%
  293.   %
  294.   \expandafter\ifx\csname E\endthing\endcsname\relax
  295.     \expandafter\ifx\csname \endthing\endcsname\relax
  296.       % There's no \foo, i.e., no ``environment'' foo.
  297.       \errhelp = \EMsimple
  298.       \errmessage{Undefined command `@end \endthing'}%
  299.     \else
  300.       \unmatchedenderror\endthing
  301.     \fi
  302.   \else
  303.     % Everything's ok; the right environment has been started.
  304.     \csname E\endthing\endcsname
  305.   \fi
  306. }
  307.  
  308. % There is an environment #1, but it hasn't been started.  Give an error.
  309. %
  310. \def\unmatchedenderror#1{%
  311.   \errhelp = \EMsimple
  312.   \errmessage{This `@end #1' doesn't have a matching `@#1'}%
  313. }
  314.  
  315. % Define the control sequence \E#1 to give an unmatched @end error.
  316. %
  317. \def\defineunmatchedend#1{%
  318.   \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
  319. }
  320.  
  321.  
  322. % Single-spacing is done by various environments (specifically, in
  323. % \nonfillstart and \quotations).
  324. \newskip\singlespaceskip \singlespaceskip = 12.5pt
  325. \def\singlespace{%
  326.   % Why was this kern here?  It messes up equalizing space above and below
  327.   % environments.  --karl, 6may93
  328.   %{\advance \baselineskip by -\singlespaceskip
  329.   %\kern \baselineskip}%
  330.   \setleading \singlespaceskip
  331. }
  332.  
  333. %% Simple single-character @ commands
  334.  
  335. % @@ prints an @
  336. % Kludge this until the fonts are right (grr).
  337. \def\@{{\tt \char '100}}
  338.  
  339. % This is turned off because it was never documented
  340. % and you can use @w{...} around a quote to suppress ligatures.
  341. %% Define @` and @' to be the same as ` and '
  342. %% but suppressing ligatures.
  343. %\def\`{{`}}
  344. %\def\'{{'}}
  345.  
  346. % Used to generate quoted braces.
  347.  
  348. \def\mylbrace {{\tt \char '173}}
  349. \def\myrbrace {{\tt \char '175}}
  350. \let\{=\mylbrace
  351. \let\}=\myrbrace
  352.  
  353. % @: forces normal size whitespace following.
  354. \def\:{\spacefactor=1000 }
  355.  
  356. % @* forces a line break.
  357. \def\*{\hfil\break\hbox{}\ignorespaces}
  358.  
  359. % @. is an end-of-sentence period.
  360. \def\.{.\spacefactor=3000 }
  361.  
  362. % @w prevents a word break.  Without the \leavevmode, @w at the
  363. % beginning of a paragraph, when TeX is still in vertical mode, would
  364. % produce a whole line of output instead of starting the paragraph.
  365. \def\w#1{\leavevmode\hbox{#1}}
  366.  
  367. % @group ... @end group forces ... to be all on one page, by enclosing
  368. % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
  369. % to keep its height that of a normal line.  According to the rules for
  370. % \topskip (p.114 of the TeXbook), the glue inserted is
  371. % max (\topskip - \ht (first item), 0).  If that height is large,
  372. % therefore, no glue is inserted, and the space between the headline and
  373. % the text is small, which looks bad.
  374. %
  375. \def\group{\begingroup
  376.   \ifnum\catcode13=\active \else
  377.     \errhelp = \groupinvalidhelp
  378.     \errmessage{@group invalid in context where filling is enabled}%
  379.   \fi
  380.   %
  381.   % The \vtop we start below produces a box with normal height and large
  382.   % depth; thus, TeX puts \baselineskip glue before it, and (when the
  383.   % next line of text is done) \lineskip glue after it.  (See p.82 of
  384.   % the TeXbook.)  Thus, space below is not quite equal to space
  385.   % above.  But it's pretty close.
  386.   \def\Egroup{%
  387.     \egroup           % End the \vtop.
  388.     \endgroup         % End the \group.
  389.   }%
  390.   %
  391.   \vtop\bgroup
  392.     % We have to put a strut on the last line in case the @group is in
  393.     % the midst of an example, rather than completely enclosing it.
  394.     % Otherwise, the interline space between the last line of the group
  395.     % and the first line afterwards is too small.  But we can't put the
  396.     % strut in \Egroup, since there it would be on a line by itself.
  397.     % Hence this just inserts a strut at the beginning of each line.
  398.     \everypar = {\strut}%
  399.     %
  400.     % Since we have a strut on every line, we don't need any of TeX's
  401.     % normal interline spacing.
  402.     \offinterlineskip
  403.     %
  404.     % OK, but now we have to do something about blank
  405.     % lines in the input in @example-like environments, which normally
  406.     % just turn into \lisppar, which will insert no space now that we've
  407.     % turned off the interline space.  Simplest is to make them be an
  408.     % empty paragraph.
  409.     \ifx\par\lisppar
  410.       \edef\par{\leavevmode \par}%
  411.       %
  412.       % Reset ^^M's definition to new definition of \par.
  413.       \obeylines
  414.     \fi
  415.     %
  416.     % Do @comment since we are called inside an environment such as
  417.     % @example, where each end-of-line in the input causes an
  418.     % end-of-line in the output.  We don't want the end-of-line after
  419.     % the `@group' to put extra space in the output.  Since @group
  420.     % should appear on a line by itself (according to the Texinfo
  421.     % manual), we don't worry about eating any user text.
  422.     \comment
  423. }
  424. %
  425. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  426. % message, so this ends up printing `@group can only ...'.
  427. %
  428. \newhelp\groupinvalidhelp{%
  429. group can only be used in environments such as @example,^^J%
  430. where each line of input produces a line of output.}
  431.  
  432. % @need space-in-mils
  433. % forces a page break if there is not space-in-mils remaining.
  434.  
  435. \newdimen\mil  \mil=0.001in
  436.  
  437. \def\need{\parsearg\needx}
  438.  
  439. % Old definition--didn't work.
  440. %\def\needx #1{\par %
  441. %% This method tries to make TeX break the page naturally
  442. %% if the depth of the box does not fit.
  443. %{\baselineskip=0pt%
  444. %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
  445. %\prevdepth=-1000pt
  446. %}}
  447.  
  448. \def\needx#1{%
  449.   % Go into vertical mode, so we don't make a big box in the middle of a
  450.   % paragraph.
  451.   \par
  452.   %
  453.   % Don't add any leading before our big empty box, but allow a page
  454.   % break, since the best break might be right here.
  455.   \allowbreak
  456.   \nointerlineskip
  457.   \vtop to #1\mil{\vfil}%
  458.   %
  459.   % TeX does not even consider page breaks if a penalty added to the
  460.   % main vertical list is 10000 or more.  But in order to see if the
  461.   % empty box we just added fits on the page, we must make it consider
  462.   % page breaks.  On the other hand, we don't want to actually break the
  463.   % page after the empty box.  So we use a penalty of 9999.
  464.   %
  465.   % There is an extremely small chance that TeX will actually break the
  466.   % page at this \penalty, if there are no other feasible breakpoints in
  467.   % sight.  (If the user is using lots of big @group commands, which
  468.   % almost-but-not-quite fill up a page, TeX will have a hard time doing
  469.   % good page breaking, for example.)  However, I could not construct an
  470.   % example where a page broke at this \penalty; if it happens in a real
  471.   % document, then we can reconsider our strategy.
  472.   \penalty9999
  473.   %
  474.   % Back up by the size of the box, whether we did a page break or not.
  475.   \kern -#1\mil
  476.   %
  477.   % Do not allow a page break right after this kern.
  478.   \nobreak
  479. }
  480.  
  481. % @br   forces paragraph break
  482.  
  483. \let\br = \par
  484.  
  485. % @dots{}  output some dots
  486.  
  487. \def\dots{$\ldots$}
  488.  
  489. % @page    forces the start of a new page
  490.  
  491. \def\page{\par\vfill\supereject}
  492.  
  493. % @exdent text....
  494. % outputs text on separate line in roman font, starting at standard page margin
  495.  
  496. % This records the amount of indent in the innermost environment.
  497. % That's how much \exdent should take out.
  498. \newskip\exdentamount
  499.  
  500. % This defn is used inside fill environments such as @defun.
  501. \def\exdent{\parsearg\exdentyyy}
  502. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  503.  
  504. % This defn is used inside nofill environments such as @example.
  505. \def\nofillexdent{\parsearg\nofillexdentyyy}
  506. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  507. \leftline{\hskip\leftskip{\rm#1}}}}
  508.  
  509. %\hbox{{\rm#1}}\hfil\break}}
  510.  
  511. % @include file    insert text of that file as input.
  512.  
  513. \def\include{\parsearg\includezzz}
  514. %Use \input\thisfile to avoid blank after \input, which may be an active
  515. %char (in which case the blank would become the \input argument).
  516. %The grouping keeps the value of \thisfile correct even when @include
  517. %is nested.
  518. \def\includezzz #1{\begingroup
  519. \def\thisfile{#1}\input\thisfile
  520. \endgroup}
  521.  
  522. \def\thisfile{}
  523.  
  524. % @center line   outputs that line, centered
  525.  
  526. \def\center{\parsearg\centerzzz}
  527. \def\centerzzz #1{{\advance\hsize by -\leftskip
  528. \advance\hsize by -\rightskip
  529. \centerline{#1}}}
  530.  
  531. % @sp n   outputs n lines of vertical space
  532.  
  533. \def\sp{\parsearg\spxxx}
  534. \def\spxxx #1{\par \vskip #1\baselineskip}
  535.  
  536. % @comment ...line which is ignored...
  537. % @c is the same as @comment
  538. % @ignore ... @end ignore  is another way to write a comment
  539.  
  540. \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
  541. \parsearg \commentxxx}
  542.  
  543. \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
  544.  
  545. \let\c=\comment
  546.  
  547. % Prevent errors for section commands.
  548. % Used in @ignore and in failing conditionals.
  549. \def\ignoresections{%
  550. \let\chapter=\relax
  551. \let\unnumbered=\relax
  552. \let\top=\relax
  553. \let\unnumberedsec=\relax
  554. \let\unnumberedsection=\relax
  555. \let\unnumberedsubsec=\relax
  556. \let\unnumberedsubsection=\relax
  557. \let\unnumberedsubsubsec=\relax
  558. \let\unnumberedsubsubsection=\relax
  559. \let\section=\relax
  560. \let\subsec=\relax
  561. \let\subsubsec=\relax
  562. \let\subsection=\relax
  563. \let\subsubsection=\relax
  564. \let\appendix=\relax
  565. \let\appendixsec=\relax
  566. \let\appendixsection=\relax
  567. \let\appendixsubsec=\relax
  568. \let\appendixsubsection=\relax
  569. \let\appendixsubsubsec=\relax
  570. \let\appendixsubsubsection=\relax
  571. \let\contents=\relax
  572. \let\smallbook=\relax
  573. \let\titlepage=\relax
  574. }
  575.  
  576. % Used in nested conditionals, where we have to parse the Texinfo source
  577. % and so want to turn off most commands, in case they are used
  578. % incorrectly.
  579. %
  580. \def\ignoremorecommands{%
  581.   \let\defcv = \relax
  582.   \let\deffn = \relax
  583.   \let\deffnx = \relax
  584.   \let\defindex = \relax
  585.   \let\defivar = \relax
  586.   \let\defmac = \relax
  587.   \let\defmethod = \relax
  588.   \let\defop = \relax
  589.   \let\defopt = \relax
  590.   \let\defspec = \relax
  591.   \let\deftp = \relax
  592.   \let\deftypefn = \relax
  593.   \let\deftypefun = \relax
  594.   \let\deftypevar = \relax
  595.   \let\deftypevr = \relax
  596.   \let\defun = \relax
  597.   \let\defvar = \relax
  598.   \let\defvr = \relax
  599.   \let\ref = \relax
  600.   \let\xref = \relax
  601.   \let\printindex = \relax
  602.   \let\pxref = \relax
  603.   \let\settitle = \relax
  604.   \let\include = \relax
  605.   \let\lowersections = \relax
  606.   \let\down = \relax
  607.   \let\raisesections = \relax
  608.   \let\up = \relax
  609.   \let\set = \relax
  610.   \let\clear = \relax
  611.   \let\item = \relax
  612.   \let\message = \relax
  613. }
  614.  
  615. % Ignore @ignore ... @end ignore.
  616. %
  617. \def\ignore{\doignore{ignore}}
  618.  
  619. % Also ignore @ifinfo, @menu, and @direntry text.
  620. %
  621. \def\ifinfo{\doignore{ifinfo}}
  622. \def\menu{\doignore{menu}}
  623. \def\direntry{\doignore{direntry}}
  624.  
  625. % Ignore text until a line `@end #1'.
  626. %
  627. \def\doignore#1{\begingroup
  628.   % Don't complain about control sequences we have declared \outer.
  629.   \ignoresections
  630.   %
  631.   % Define a command to swallow text until we reach `@end #1'.
  632.   \long\def\doignoretext##1\end #1{\enddoignore}%
  633.   %
  634.   % Make sure that spaces turn into tokens that match what \doignoretext wants.
  635.   \catcode32 = 10
  636.   %
  637.   % And now expand that command.
  638.   \doignoretext
  639. }
  640.  
  641. % What we do to finish off ignored text.
  642. %
  643. \def\enddoignore{\endgroup\ignorespaces}%
  644.  
  645. \newif\ifwarnedobs\warnedobsfalse
  646. \def\obstexwarn{%
  647.   \ifwarnedobs\relax\else
  648.   % We need to warn folks that they may have trouble with TeX 3.0.
  649.   % This uses \immediate\write16 rather than \message to get newlines.
  650.     \immediate\write16{}
  651.     \immediate\write16{***WARNING*** for users of Unix TeX 3.0!}
  652.     \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
  653.     \immediate\write16{If you are running another version of TeX, relax.}
  654.     \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
  655.     \immediate\write16{  Then upgrade your TeX installation if you can.}
  656.     \immediate\write16{If you are stuck with version 3.0, run the}
  657.     \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
  658.     \immediate\write16{  to use a workaround.}
  659.     \immediate\write16{}
  660.     \warnedobstrue
  661.     \fi
  662. }
  663.  
  664. % **In TeX 3.0, setting text in \nullfont hangs tex.  For a
  665. % workaround (which requires the file ``dummy.tfm'' to be installed),
  666. % uncomment the following line:
  667. %%%%%\font\nullfont=dummy\let\obstexwarn=\relax
  668.  
  669. % Ignore text, except that we keep track of conditional commands for
  670. % purposes of nesting, up to an `@end #1' command.
  671. %
  672. \def\nestedignore#1{%
  673.   \obstexwarn
  674.   % We must actually expand the ignored text to look for the @end
  675.   % command, so that nested ignore constructs work.  Thus, we put the
  676.   % text into a \vbox and then do nothing with the result.  To minimize
  677.   % the change of memory overflow, we follow the approach outlined on
  678.   % page 401 of the TeXbook: make the current font be a dummy font.
  679.   %
  680.   \setbox0 = \vbox\bgroup
  681.     % Don't complain about control sequences we have declared \outer.
  682.     \ignoresections
  683.     %
  684.     % Define `@end #1' to end the box, which will in turn undefine the
  685.     % @end command again.
  686.     \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
  687.     %
  688.     % We are going to be parsing Texinfo commands.  Most cause no
  689.     % trouble when they are used incorrectly, but some commands do
  690.     % complicated argument parsing or otherwise get confused, so we
  691.     % undefine them.
  692.     %
  693.     % We can't do anything about stray @-signs, unfortunately;
  694.     % they'll produce `undefined control sequence' errors.
  695.     \ignoremorecommands
  696.     %
  697.     % Set the current font to be \nullfont, a TeX primitive, and define
  698.     % all the font commands to also use \nullfont.  We don't use
  699.     % dummy.tfm, as suggested in the TeXbook, because not all sites
  700.     % might have that installed.  Therefore, math mode will still
  701.     % produce output, but that should be an extremely small amount of
  702.     % stuff compared to the main input.
  703.     %
  704.     \nullfont
  705.     \let\tenrm = \nullfont  \let\tenit = \nullfont  \let\tensl = \nullfont
  706.     \let\tenbf = \nullfont  \let\tentt = \nullfont  \let\smallcaps = \nullfont
  707.     \let\tensf = \nullfont
  708.     % Similarly for index fonts (mostly for their use in
  709.     % smallexample)
  710.     \let\indrm = \nullfont  \let\indit = \nullfont  \let\indsl = \nullfont
  711.     \let\indbf = \nullfont  \let\indtt = \nullfont  \let\indsc = \nullfont
  712.     \let\indsf = \nullfont
  713.     %
  714.     % Don't complain when characters are missing from the fonts.
  715.     \tracinglostchars = 0
  716.     %
  717.     % Don't bother to do space factor calculations.
  718.     \frenchspacing
  719.     %
  720.     % Don't report underfull hboxes.
  721.     \hbadness = 10000
  722.     %
  723.     % Do minimal line-breaking.
  724.     \pretolerance = 10000
  725.     %
  726.     % Do not execute instructions in @tex
  727.     \def\tex{\doignore{tex}}
  728. }
  729.  
  730. % @set VAR sets the variable VAR to an empty value.
  731. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
  732. %
  733. % Since we want to separate VAR from REST-OF-LINE (which might be
  734. % empty), we can't just use \parsearg; we have to insert a space of our
  735. % own to delimit the rest of the line, and then take it out again if we
  736. % didn't need it.
  737. %
  738. \def\set{\parsearg\setxxx}
  739. \def\setxxx#1{\setyyy#1 \endsetyyy}
  740. \def\setyyy#1 #2\endsetyyy{%
  741.   \def\temp{#2}%
  742.   \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
  743.   \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
  744.   \fi
  745. }
  746. \def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}}
  747.  
  748. % @clear VAR clears (i.e., unsets) the variable VAR.
  749. %
  750. \def\clear{\parsearg\clearxxx}
  751. \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
  752.  
  753. % @value{foo} gets the text saved in variable foo.
  754. %
  755. \def\value#1{\expandafter
  756.         \ifx\csname SET#1\endcsname\relax
  757.             {\{No value for ``#1''\}}
  758.         \else \csname SET#1\endcsname \fi}
  759.  
  760. % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  761. % with @set.
  762. %
  763. \def\ifset{\parsearg\ifsetxxx}
  764. \def\ifsetxxx #1{%
  765.   \expandafter\ifx\csname SET#1\endcsname\relax
  766.     \expandafter\ifsetfail
  767.   \else
  768.     \expandafter\ifsetsucceed
  769.   \fi
  770. }
  771. \def\ifsetsucceed{\conditionalsucceed{ifset}}
  772. \def\ifsetfail{\nestedignore{ifset}}
  773. \defineunmatchedend{ifset}
  774.  
  775. % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  776. % defined with @set, or has been undefined with @clear.
  777. %
  778. \def\ifclear{\parsearg\ifclearxxx}
  779. \def\ifclearxxx #1{%
  780.   \expandafter\ifx\csname SET#1\endcsname\relax
  781.     \expandafter\ifclearsucceed
  782.   \else
  783.     \expandafter\ifclearfail
  784.   \fi
  785. }
  786. \def\ifclearsucceed{\conditionalsucceed{ifclear}}
  787. \def\ifclearfail{\nestedignore{ifclear}}
  788. \defineunmatchedend{ifclear}
  789.  
  790. % @iftex always succeeds; we read the text following, through @end
  791. % iftex).  But `@end iftex' should be valid only after an @iftex.
  792. %
  793. \def\iftex{\conditionalsucceed{iftex}}
  794. \defineunmatchedend{iftex}
  795.  
  796. % We can't just want to start a group at @iftex (for example) and end it
  797. % at @end iftex, since then @set commands inside the conditional have no
  798. % effect (they'd get reverted at the end of the group).  So we must
  799. % define \Eiftex to redefine itself to be its previous value.  (We can't
  800. % just define it to fail again with an ``unmatched end'' error, since
  801. % the @ifset might be nested.)
  802. %
  803. \def\conditionalsucceed#1{%
  804.   \edef\temp{%
  805.     % Remember the current value of \E#1.
  806.     \let\nece{prevE#1} = \nece{E#1}%
  807.     %
  808.     % At the `@end #1', redefine \E#1 to be its previous value.
  809.     \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
  810.   }%
  811.   \temp
  812. }
  813.  
  814. % We need to expand lots of \csname's, but we don't want to expand the
  815. % control sequences after we've constructed them.
  816. %
  817. \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
  818.  
  819. % @asis just yields its argument.  Used with @table, for example.
  820. %
  821. \def\asis#1{#1}
  822.  
  823. % @math means output in math mode.
  824. % We don't use $'s directly in the definition of \math because control
  825. % sequences like \math are expanded when the toc file is written.  Then,
  826. % we read the toc file back, the $'s will be normal characters (as they
  827. % should be, according to the definition of Texinfo).  So we must use a
  828. % control sequence to switch into and out of math mode.
  829. %
  830. % This isn't quite enough for @math to work properly in indices, but it
  831. % seems unlikely it will ever be needed there.
  832. %
  833. \let\implicitmath = $
  834. \def\math#1{\implicitmath #1\implicitmath}
  835.  
  836. % @bullet and @minus need the same treatment as @math, just above.
  837. \def\bullet{\implicitmath\ptexbullet\implicitmath}
  838. \def\minus{\implicitmath-\implicitmath}
  839.  
  840. \def\node{\ENVcheck\parsearg\nodezzz}
  841. \def\nodezzz#1{\nodexxx [#1,]}
  842. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  843. \let\nwnode=\node
  844. \let\lastnode=\relax
  845.  
  846. \def\donoderef{\ifx\lastnode\relax\else
  847. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  848. \global\let\lastnode=\relax}
  849.  
  850. \def\unnumbnoderef{\ifx\lastnode\relax\else
  851. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  852. \global\let\lastnode=\relax}
  853.  
  854. \def\appendixnoderef{\ifx\lastnode\relax\else
  855. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  856. \global\let\lastnode=\relax}
  857.  
  858. \let\refill=\relax
  859.  
  860. % @setfilename is done at the beginning of every texinfo file.
  861. % So open here the files we need to have open while reading the input.
  862. % This makes it possible to make a .fmt file for texinfo.
  863. \def\setfilename{%
  864.    \readauxfile
  865.    \opencontents
  866.    \openindices
  867.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  868.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  869.    \comment % Ignore the actual filename.
  870. }
  871.  
  872. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  873.  
  874. \def\inforef #1{\inforefzzz #1,,,,**}
  875. \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
  876.   node \samp{\ignorespaces#1{}}}
  877.  
  878. \message{fonts,}
  879.  
  880. % Font-change commands.
  881.  
  882. % Texinfo supports the sans serif font style, which plain TeX does not.
  883. % So we set up a \sf analogous to plain's \rm, etc.
  884. \newfam\sffam
  885. \def\sf{\fam=\sffam \tensf}
  886. \let\li = \sf % Sometimes we call it \li, not \sf.
  887.  
  888. %% Try out Computer Modern fonts at \magstephalf
  889. \let\mainmagstep=\magstephalf
  890.  
  891. \ifx\bigger\relax
  892. \let\mainmagstep=\magstep1
  893. \font\textrm=cmr12
  894. \font\texttt=cmtt12
  895. \else
  896. \font\textrm=cmr10 scaled \mainmagstep
  897. \font\texttt=cmtt10 scaled \mainmagstep
  898. \fi
  899. % Instead of cmb10, you many want to use cmbx10.
  900. % cmbx10 is a prettier font on its own, but cmb10
  901. % looks better when embedded in a line with cmr10.
  902. \font\textbf=cmb10 scaled \mainmagstep
  903. \font\textit=cmti10 scaled \mainmagstep
  904. \font\textsl=cmsl10 scaled \mainmagstep
  905. \font\textsf=cmss10 scaled \mainmagstep
  906. \font\textsc=cmcsc10 scaled \mainmagstep
  907. \font\texti=cmmi10 scaled \mainmagstep
  908. \font\textsy=cmsy10 scaled \mainmagstep
  909.  
  910. % A few fonts for @defun, etc.
  911. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  912. \font\deftt=cmtt10 scaled \magstep1
  913. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  914.  
  915. % Fonts for indices and small examples.
  916. % We actually use the slanted font rather than the italic,
  917. % because texinfo normally uses the slanted fonts for that.
  918. % Do not make many font distinctions in general in the index, since they
  919. % aren't very useful.
  920. \font\ninett=cmtt9
  921. \font\indrm=cmr9
  922. \font\indit=cmsl9
  923. \let\indsl=\indit
  924. \let\indtt=\ninett
  925. \let\indsf=\indrm
  926. \let\indbf=\indrm
  927. \let\indsc=\indrm
  928. \font\indi=cmmi9
  929. \font\indsy=cmsy9
  930.  
  931. % Fonts for headings
  932. \font\chaprm=cmbx12 scaled \magstep2
  933. \font\chapit=cmti12 scaled \magstep2
  934. \font\chapsl=cmsl12 scaled \magstep2
  935. \font\chaptt=cmtt12 scaled \magstep2
  936. \font\chapsf=cmss12 scaled \magstep2
  937. \let\chapbf=\chaprm
  938. \font\chapsc=cmcsc10 scaled\magstep3
  939. \font\chapi=cmmi12 scaled \magstep2
  940. \font\chapsy=cmsy10 scaled \magstep3
  941.  
  942. \font\secrm=cmbx12 scaled \magstep1
  943. \font\secit=cmti12 scaled \magstep1
  944. \font\secsl=cmsl12 scaled \magstep1
  945. \font\sectt=cmtt12 scaled \magstep1
  946. \font\secsf=cmss12 scaled \magstep1
  947. \font\secbf=cmbx12 scaled \magstep1
  948. \font\secsc=cmcsc10 scaled\magstep2
  949. \font\seci=cmmi12 scaled \magstep1
  950. \font\secsy=cmsy10 scaled \magstep2
  951.  
  952. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an font looked bad.
  953. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  954. % \font\ssecsl=cmsl10 scaled \magstep1
  955. % \font\ssectt=cmtt10 scaled \magstep1
  956. % \font\ssecsf=cmss10 scaled \magstep1
  957.  
  958. %\font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  959. %\font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  960. %\font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  961. %\font\ssectt=cmtt10 scaled 1315
  962. %\font\ssecsf=cmss10 scaled 1315
  963.  
  964. %\let\ssecbf=\ssecrm
  965.  
  966. \font\ssecrm=cmbx12 scaled \magstephalf
  967. \font\ssecit=cmti12 scaled \magstephalf
  968. \font\ssecsl=cmsl12 scaled \magstephalf
  969. \font\ssectt=cmtt12 scaled \magstephalf
  970. \font\ssecsf=cmss12 scaled \magstephalf
  971. \font\ssecbf=cmbx12 scaled \magstephalf
  972. \font\ssecsc=cmcsc10 scaled \magstep1
  973. \font\sseci=cmmi12 scaled \magstephalf
  974. \font\ssecsy=cmsy10 scaled \magstep1
  975. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  976. % but that is not a standard magnification.
  977.  
  978. % Fonts for title page:
  979. \font\titlerm = cmbx12 scaled \magstep3
  980. \let\authorrm = \secrm
  981.  
  982. % In order for the font changes to affect most math symbols and letters,
  983. % we have to define the \textfont of the standard families.  Since
  984. % texinfo doesn't allow for producing subscripts and superscripts, we
  985. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  986. % also require loading a lot more fonts).
  987. %
  988. \def\resetmathfonts{%
  989.   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  990.   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  991.   \textfont\ttfam = \tentt \textfont\sffam = \tensf
  992. }
  993.  
  994.  
  995. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  996. % of just \STYLE.  We do this so that font changes will continue to work
  997. % in math mode, where it is the current \fam that is relevant in most
  998. % cases, not the current.  Plain TeX does, for example,
  999. % \def\bf{\fam=\bffam \tenbf}  By redefining \tenbf, we obviate the need
  1000. % to redefine \bf itself.
  1001. \def\textfonts{%
  1002.   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  1003.   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  1004.   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
  1005.   \resetmathfonts}
  1006. \def\chapfonts{%
  1007.   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
  1008.   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  1009.   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
  1010.   \resetmathfonts}
  1011. \def\secfonts{%
  1012.   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  1013.   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  1014.   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
  1015.   \resetmathfonts}
  1016. \def\subsecfonts{%
  1017.   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  1018.   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  1019.   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
  1020.   \resetmathfonts}
  1021. \def\indexfonts{%
  1022.   \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
  1023.   \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
  1024.   \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
  1025.   \resetmathfonts}
  1026.  
  1027. % Set up the default fonts, so we can use them for creating boxes.
  1028. %
  1029. \textfonts
  1030.  
  1031. % Count depth in font-changes, for error checks
  1032. \newcount\fontdepth \fontdepth=0
  1033.  
  1034. % Fonts for short table of contents.
  1035. \font\shortcontrm=cmr12
  1036. \font\shortcontbf=cmbx12
  1037. \font\shortcontsl=cmsl12
  1038.  
  1039. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  1040. %% serif) and @ii for TeX italic
  1041.  
  1042. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  1043. % unless the following character is such as not to need one.
  1044. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  1045. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  1046.  
  1047. \let\i=\smartitalic
  1048. \let\var=\smartitalic
  1049. \let\dfn=\smartitalic
  1050. \let\emph=\smartitalic
  1051. \let\cite=\smartitalic
  1052.  
  1053. \def\b#1{{\bf #1}}
  1054. \let\strong=\b
  1055.  
  1056. % We can't just use \exhyphenpenalty, because that only has effect at
  1057. % the end of a paragraph.  Restore normal hyphenation at the end of the
  1058. % group within which \nohyphenation is presumably called.
  1059. %
  1060. \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
  1061. \def\restorehyphenation{\hyphenchar\font = `- }
  1062.  
  1063. \def\t#1{%
  1064.   {\tt \nohyphenation \rawbackslash \frenchspacing #1}%
  1065.   \null
  1066. }
  1067. \let\ttfont = \t
  1068. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  1069. \def\samp #1{`\tclose{#1}'\null}
  1070. \def\key #1{{\tt \nohyphenation \uppercase{#1}}\null}
  1071. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  1072.  
  1073. \let\file=\samp
  1074.  
  1075. % @code is a modification of @t,
  1076. % which makes spaces the same size as normal in the surrounding text.
  1077. \def\tclose#1{%
  1078.   {%
  1079.     % Change normal interword space to be same as for the current font.
  1080.     \spaceskip = \fontdimen2\font
  1081.     %
  1082.     % Switch to typewriter.
  1083.     \tt
  1084.     %
  1085.     % But `\ ' produces the large typewriter interword space.
  1086.     \def\ {{\spaceskip = 0pt{} }}%
  1087.     %
  1088.     % Turn off hyphenation.
  1089.     \nohyphenation
  1090.     %
  1091.     \rawbackslash
  1092.     \frenchspacing
  1093.     #1%
  1094.   }%
  1095.   \null
  1096. }
  1097.  
  1098. % We *must* turn on hyphenation at `-' and `_' in \code.
  1099. % Otherwise, it is too hard to avoid overful hboxes
  1100. % in the Emacs manual, the Library manual, etc.
  1101.  
  1102. % Unfortunately, TeX uses one parameter (\hyphenchar) to control
  1103. % both hyphenation at - and hyphenation within words.
  1104. % We must therefore turn them both off (\tclose does that)
  1105. % and arrange explicitly to hyphenate an a dash.
  1106. %  -- rms.
  1107. {
  1108. \catcode`\-=\active
  1109. \catcode`\_=\active
  1110. \global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex}
  1111. % The following is used by \doprintindex to insure that long function names
  1112. % wrap around.  It is necessary for - and _ to be active before the index is
  1113. % read from the file, as \entry parses the arguments long before \code is
  1114. % ever called.  -- mycroft
  1115. \global\def\indexbreaks{\catcode`\-=\active \let-\realdash \catcode`\_=\active \let_\realunder}
  1116. }
  1117. \def\realdash{-}
  1118. \def\realunder{_}
  1119. \def\codedash{-\discretionary{}{}{}}
  1120. \def\codeunder{\normalunderscore\discretionary{}{}{}}
  1121. \def\codex #1{\tclose{#1}\endgroup}
  1122.  
  1123. %\let\exp=\tclose  %Was temporary
  1124.  
  1125. % @kbd is like @code, except that if the argument is just one @key command,
  1126. % then @kbd has no effect.
  1127.  
  1128. \def\xkey{\key}
  1129. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  1130. \ifx\one\xkey\ifx\threex\three \key{#2}%
  1131. \else\tclose{\look}\fi
  1132. \else\tclose{\look}\fi}
  1133.  
  1134. % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  1135. % argument is to make the input look right: @dmn{pt} instead of
  1136. % @dmn{}pt.
  1137. %
  1138. \def\dmn#1{\thinspace #1}
  1139.  
  1140. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  1141.  
  1142. \def\l#1{{\li #1}\null}        %
  1143.  
  1144. \def\r#1{{\rm #1}}        % roman font
  1145. % Use of \lowercase was suggested.
  1146. \def\sc#1{{\smallcaps#1}}    % smallcaps font
  1147. \def\ii#1{{\it #1}}        % italic font
  1148.  
  1149. \message{page headings,}
  1150.  
  1151. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  1152. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  1153.  
  1154. % First the title page.  Must do @settitle before @titlepage.
  1155. \def\titlefont#1{{\titlerm #1}}
  1156.  
  1157. \newif\ifseenauthor
  1158. \newif\iffinishedtitlepage
  1159.  
  1160. \def\shorttitlepage{\parsearg\shorttitlepagezzz}
  1161. \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
  1162.     \endgroup\page\hbox{}\page}
  1163.  
  1164. \def\titlepage{\begingroup \parindent=0pt \textfonts
  1165.    \let\subtitlerm=\tenrm
  1166. % I deinstalled the following change because \cmr12 is undefined.
  1167. % This change was not in the ChangeLog anyway.  --rms.
  1168. %   \let\subtitlerm=\cmr12
  1169.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  1170.    %
  1171.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  1172.    %
  1173.    % Leave some space at the very top of the page.
  1174.    \vglue\titlepagetopglue
  1175.    %
  1176.    % Now you can print the title using @title.
  1177.    \def\title{\parsearg\titlezzz}%
  1178.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  1179.             % print a rule at the page bottom also.
  1180.             \finishedtitlepagefalse
  1181.             \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
  1182.    % No rule at page bottom unless we print one at the top with @title.
  1183.    \finishedtitlepagetrue
  1184.    %
  1185.    % Now you can put text using @subtitle.
  1186.    \def\subtitle{\parsearg\subtitlezzz}%
  1187.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  1188.    %
  1189.    % @author should come last, but may come many times.
  1190.    \def\author{\parsearg\authorzzz}%
  1191.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  1192.       {\authorfont \leftline{##1}}}%
  1193.    %
  1194.    % Most title ``pages'' are actually two pages long, with space
  1195.    % at the top of the second.  We don't want the ragged left on the second.
  1196.    \let\oldpage = \page
  1197.    \def\page{%
  1198.       \iffinishedtitlepage\else
  1199.      \finishtitlepage
  1200.       \fi
  1201.       \oldpage
  1202.       \let\page = \oldpage
  1203.       \hbox{}}%
  1204. %   \def\page{\oldpage \hbox{}}
  1205. }
  1206.  
  1207. \def\Etitlepage{%
  1208.    \iffinishedtitlepage\else
  1209.       \finishtitlepage
  1210.    \fi
  1211.    % It is important to do the page break before ending the group,
  1212.    % because the headline and footline are only empty inside the group.
  1213.    % If we use the new definition of \page, we always get a blank page
  1214.    % after the title page, which we certainly don't want.
  1215.    \oldpage
  1216.    \endgroup
  1217.    \HEADINGSon
  1218. }
  1219.  
  1220. \def\finishtitlepage{%
  1221.    \vskip4pt \hrule height 2pt width \hsize
  1222.    \vskip\titlepagebottomglue
  1223.    \finishedtitlepagetrue
  1224. }
  1225.  
  1226. %%% Set up page headings and footings.
  1227.  
  1228. \let\thispage=\folio
  1229.  
  1230. \newtoks \evenheadline    % Token sequence for heading line of even pages
  1231. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  1232. \newtoks \evenfootline    % Token sequence for footing line of even pages
  1233. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  1234.  
  1235. % Now make Tex use those variables
  1236. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  1237.                             \else \the\evenheadline \fi}}
  1238. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  1239.                             \else \the\evenfootline \fi}\HEADINGShook}
  1240. \let\HEADINGShook=\relax
  1241.  
  1242. % Commands to set those variables.
  1243. % For example, this is what  @headings on  does
  1244. % @evenheading @thistitle|@thispage|@thischapter
  1245. % @oddheading @thischapter|@thispage|@thistitle
  1246. % @evenfooting @thisfile||
  1247. % @oddfooting ||@thisfile
  1248.  
  1249. \def\evenheading{\parsearg\evenheadingxxx}
  1250. \def\oddheading{\parsearg\oddheadingxxx}
  1251. \def\everyheading{\parsearg\everyheadingxxx}
  1252.  
  1253. \def\evenfooting{\parsearg\evenfootingxxx}
  1254. \def\oddfooting{\parsearg\oddfootingxxx}
  1255. \def\everyfooting{\parsearg\everyfootingxxx}
  1256.  
  1257. {\catcode`\@=0 %
  1258.  
  1259. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  1260. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  1261. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1262.  
  1263. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  1264. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  1265. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1266.  
  1267. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  1268. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  1269. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  1270. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1271.  
  1272. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  1273. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  1274. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1275.  
  1276. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  1277. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  1278. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1279.  
  1280. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  1281. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  1282. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  1283. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1284. %
  1285. }% unbind the catcode of @.
  1286.  
  1287. % @headings double    turns headings on for double-sided printing.
  1288. % @headings single    turns headings on for single-sided printing.
  1289. % @headings off        turns them off.
  1290. % @headings on        same as @headings double, retained for compatibility.
  1291. % @headings after    turns on double-sided headings after this page.
  1292. % @headings doubleafter    turns on double-sided headings after this page.
  1293. % @headings singleafter turns on single-sided headings after this page.
  1294. % By default, they are off.
  1295.  
  1296. \def\headings #1 {\csname HEADINGS#1\endcsname}
  1297.  
  1298. \def\HEADINGSoff{
  1299. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  1300. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  1301. \HEADINGSoff
  1302. % When we turn headings on, set the page number to 1.
  1303. % For double-sided printing, put current file name in lower left corner,
  1304. % chapter name on inside top of right hand pages, document
  1305. % title on inside top of left hand pages, and page numbers on outside top
  1306. % edge of all pages.
  1307. \def\HEADINGSdouble{
  1308. %\pagealignmacro
  1309. \global\pageno=1
  1310. \global\evenfootline={\hfil}
  1311. \global\oddfootline={\hfil}
  1312. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1313. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1314. }
  1315. % For single-sided printing, chapter title goes across top left of page,
  1316. % page number on top right.
  1317. \def\HEADINGSsingle{
  1318. %\pagealignmacro
  1319. \global\pageno=1
  1320. \global\evenfootline={\hfil}
  1321. \global\oddfootline={\hfil}
  1322. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1323. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1324. }
  1325. \def\HEADINGSon{\HEADINGSdouble}
  1326.  
  1327. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  1328. \let\HEADINGSdoubleafter=\HEADINGSafter
  1329. \def\HEADINGSdoublex{%
  1330. \global\evenfootline={\hfil}
  1331. \global\oddfootline={\hfil}
  1332. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1333. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1334. }
  1335.  
  1336. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  1337. \def\HEADINGSsinglex{%
  1338. \global\evenfootline={\hfil}
  1339. \global\oddfootline={\hfil}
  1340. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1341. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1342. }
  1343.  
  1344. % Subroutines used in generating headings
  1345. % Produces Day Month Year style of output.
  1346. \def\today{\number\day\space
  1347. \ifcase\month\or
  1348. January\or February\or March\or April\or May\or June\or
  1349. July\or August\or September\or October\or November\or December\fi
  1350. \space\number\year}
  1351.  
  1352. % Use this if you want the Month Day, Year style of output.
  1353. %\def\today{\ifcase\month\or
  1354. %January\or February\or March\or April\or May\or June\or
  1355. %July\or August\or September\or October\or November\or December\fi
  1356. %\space\number\day, \number\year}
  1357.  
  1358. % @settitle line...  specifies the title of the document, for headings
  1359. % It generates no output of its own
  1360.  
  1361. \def\thistitle{No Title}
  1362. \def\settitle{\parsearg\settitlezzz}
  1363. \def\settitlezzz #1{\gdef\thistitle{#1}}
  1364.  
  1365. \message{tables,}
  1366.  
  1367. % @tabs -- simple alignment
  1368.  
  1369. % These don't work.  For one thing, \+ is defined as outer.
  1370. % So these macros cannot even be defined.
  1371.  
  1372. %\def\tabs{\parsearg\tabszzz}
  1373. %\def\tabszzz #1{\settabs\+#1\cr}
  1374. %\def\tabline{\parsearg\tablinezzz}
  1375. %\def\tablinezzz #1{\+#1\cr}
  1376. %\def\&{&}
  1377.  
  1378. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  1379.  
  1380. % default indentation of table text
  1381. \newdimen\tableindent \tableindent=.8in
  1382. % default indentation of @itemize and @enumerate text
  1383. \newdimen\itemindent  \itemindent=.3in
  1384. % margin between end of table item and start of table text.
  1385. \newdimen\itemmargin  \itemmargin=.1in
  1386.  
  1387. % used internally for \itemindent minus \itemmargin
  1388. \newdimen\itemmax
  1389.  
  1390. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  1391. % these defs.
  1392. % They also define \itemindex
  1393. % to index the item name in whatever manner is desired (perhaps none).
  1394.  
  1395. \newif\ifitemxneedsnegativevskip
  1396.  
  1397. \def\itemxpar{\par\ifitemxneedsnegativevskip\vskip-\parskip\nobreak\fi}
  1398.  
  1399. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  1400. \def\internalBitemx{\itemxpar \parsearg\itemzzz}
  1401.  
  1402. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  1403. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
  1404.  
  1405. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  1406. \def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
  1407.  
  1408. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  1409.                  \itemzzz {#1}}
  1410.  
  1411. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  1412.                  \itemzzz {#1}}
  1413.  
  1414. \def\itemzzz #1{\begingroup %
  1415.   \advance\hsize by -\rightskip
  1416.   \advance\hsize by -\tableindent
  1417.   \setbox0=\hbox{\itemfont{#1}}%
  1418.   \itemindex{#1}%
  1419.   \nobreak % This prevents a break before @itemx.
  1420.   %
  1421.   % Be sure we are not still in the middle of a paragraph.
  1422.   %{\parskip = 0in
  1423.   %\par
  1424.   %}%
  1425.   %
  1426.   % If the item text does not fit in the space we have, put it on a line
  1427.   % by itself, and do not allow a page break either before or after that
  1428.   % line.  We do not start a paragraph here because then if the next
  1429.   % command is, e.g., @kindex, the whatsit would get put into the
  1430.   % horizontal list on a line by itself, resulting in extra blank space.
  1431.   \ifdim \wd0>\itemmax
  1432.     %
  1433.     % Make this a paragraph so we get the \parskip glue and wrapping,
  1434.     % but leave it ragged-right.
  1435.     \begingroup
  1436.       \advance\leftskip by-\tableindent
  1437.       \advance\hsize by\tableindent
  1438.       \advance\rightskip by0pt plus1fil
  1439.       \leavevmode\unhbox0\par
  1440.     \endgroup
  1441.     %
  1442.     % We're going to be starting a paragraph, but we don't want the
  1443.     % \parskip glue -- logically it's part of the @item we just started.
  1444.     \nobreak \vskip-\parskip
  1445.     %
  1446.     % Stop a page break at the \parskip glue coming up.  Unfortunately
  1447.     % we can't prevent a possible page break at the following
  1448.     % \baselineskip glue.
  1449.     \nobreak
  1450.     \endgroup
  1451.     \itemxneedsnegativevskipfalse
  1452.   \else
  1453.     % The item text fits into the space.  Start a paragraph, so that the
  1454.     % following text (if any) will end up on the same line.  Since that
  1455.     % text will be indented by \tableindent, we make the item text be in
  1456.     % a zero-width box.
  1457.     \noindent
  1458.     \rlap{\hskip -\tableindent\box0}\ignorespaces%
  1459.     \endgroup%
  1460.     \itemxneedsnegativevskiptrue%
  1461.   \fi
  1462. }
  1463.  
  1464. \def\item{\errmessage{@item while not in a table}}
  1465. \def\itemx{\errmessage{@itemx while not in a table}}
  1466. \def\kitem{\errmessage{@kitem while not in a table}}
  1467. \def\kitemx{\errmessage{@kitemx while not in a table}}
  1468. \def\xitem{\errmessage{@xitem while not in a table}}
  1469. \def\xitemx{\errmessage{@xitemx while not in a table}}
  1470.  
  1471. %% Contains a kludge to get @end[description] to work
  1472. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  1473.  
  1474. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  1475. {\obeylines\obeyspaces%
  1476. \gdef\tablex #1^^M{%
  1477. \tabley\dontindex#1        \endtabley}}
  1478.  
  1479. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  1480. {\obeylines\obeyspaces%
  1481. \gdef\ftablex #1^^M{%
  1482. \tabley\fnitemindex#1        \endtabley
  1483. \def\Eftable{\endgraf\afterenvbreak\endgroup}%
  1484. \let\Etable=\relax}}
  1485.  
  1486. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  1487. {\obeylines\obeyspaces%
  1488. \gdef\vtablex #1^^M{%
  1489. \tabley\vritemindex#1        \endtabley
  1490. \def\Evtable{\endgraf\afterenvbreak\endgroup}%
  1491. \let\Etable=\relax}}
  1492.  
  1493. \def\dontindex #1{}
  1494. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  1495. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  1496.  
  1497. {\obeyspaces %
  1498. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  1499. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  1500.  
  1501. \def\tablez #1#2#3#4#5#6{%
  1502. \aboveenvbreak %
  1503. \begingroup %
  1504. \def\Edescription{\Etable}% Neccessary kludge.
  1505. \let\itemindex=#1%
  1506. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  1507. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  1508. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  1509. \def\itemfont{#2}%
  1510. \itemmax=\tableindent %
  1511. \advance \itemmax by -\itemmargin %
  1512. \advance \leftskip by \tableindent %
  1513. \exdentamount=\tableindent
  1514. \parindent = 0pt
  1515. \parskip = \smallskipamount
  1516. \ifdim \parskip=0pt \parskip=2pt \fi%
  1517. \def\Etable{\endgraf\afterenvbreak\endgroup}%
  1518. \let\item = \internalBitem %
  1519. \let\itemx = \internalBitemx %
  1520. \let\kitem = \internalBkitem %
  1521. \let\kitemx = \internalBkitemx %
  1522. \let\xitem = \internalBxitem %
  1523. \let\xitemx = \internalBxitemx %
  1524. }
  1525.  
  1526. % This is the counter used by @enumerate, which is really @itemize
  1527.  
  1528. \newcount \itemno
  1529.  
  1530. \def\itemize{\parsearg\itemizezzz}
  1531.  
  1532. \def\itemizezzz #1{%
  1533.   \begingroup % ended by the @end itemsize
  1534.   \itemizey {#1}{\Eitemize}
  1535. }
  1536.  
  1537. \def\itemizey #1#2{%
  1538. \aboveenvbreak %
  1539. \itemmax=\itemindent %
  1540. \advance \itemmax by -\itemmargin %
  1541. \advance \leftskip by \itemindent %
  1542. \exdentamount=\itemindent
  1543. \parindent = 0pt %
  1544. \parskip = \smallskipamount %
  1545. \ifdim \parskip=0pt \parskip=2pt \fi%
  1546. \def#2{\endgraf\afterenvbreak\endgroup}%
  1547. \def\itemcontents{#1}%
  1548. \let\item=\itemizeitem}
  1549.  
  1550. % Set sfcode to normal for the chars that usually have another value.
  1551. % These are `.?!:;,'
  1552. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  1553.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  1554.  
  1555. % \splitoff TOKENS\endmark defines \first to be the first token in
  1556. % TOKENS, and \rest to be the remainder.
  1557. %
  1558. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  1559.  
  1560. % Allow an optional argument of an uppercase letter, lowercase letter,
  1561. % or number, to specify the first label in the enumerated list.  No
  1562. % argument is the same as `1'.
  1563. %
  1564. \def\enumerate{\parsearg\enumeratezzz}
  1565. \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
  1566. \def\enumeratey #1 #2\endenumeratey{%
  1567.   \begingroup % ended by the @end enumerate
  1568.   %
  1569.   % If we were given no argument, pretend we were given `1'.
  1570.   \def\thearg{#1}%
  1571.   \ifx\thearg\empty \def\thearg{1}\fi
  1572.   %
  1573.   % Detect if the argument is a single token.  If so, it might be a
  1574.   % letter.  Otherwise, the only valid thing it can be is a number.
  1575.   % (We will always have one token, because of the test we just made.
  1576.   % This is a good thing, since \splitoff doesn't work given nothing at
  1577.   % all -- the first parameter is undelimited.)
  1578.   \expandafter\splitoff\thearg\endmark
  1579.   \ifx\rest\empty
  1580.     % Only one token in the argument.  It could still be anything.
  1581.     % A ``lowercase letter'' is one whose \lccode is nonzero.
  1582.     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  1583.     %   not equal to itself.
  1584.     % Otherwise, we assume it's a number.
  1585.     %
  1586.     % We need the \relax at the end of the \ifnum lines to stop TeX from
  1587.     % continuing to look for a <number>.
  1588.     %
  1589.     \ifnum\lccode\expandafter`\thearg=0\relax
  1590.       \numericenumerate % a number (we hope)
  1591.     \else
  1592.       % It's a letter.
  1593.       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1594.         \lowercaseenumerate % lowercase letter
  1595.       \else
  1596.         \uppercaseenumerate % uppercase letter
  1597.       \fi
  1598.     \fi
  1599.   \else
  1600.     % Multiple tokens in the argument.  We hope it's a number.
  1601.     \numericenumerate
  1602.   \fi
  1603. }
  1604.  
  1605. % An @enumerate whose labels are integers.  The starting integer is
  1606. % given in \thearg.
  1607. %
  1608. \def\numericenumerate{%
  1609.   \itemno = \thearg
  1610.   \startenumeration{\the\itemno}%
  1611. }
  1612.  
  1613. % The starting (lowercase) letter is in \thearg.
  1614. \def\lowercaseenumerate{%
  1615.   \itemno = \expandafter`\thearg
  1616.   \startenumeration{%
  1617.     % Be sure we're not beyond the end of the alphabet.
  1618.     \ifnum\itemno=0
  1619.       \errmessage{No more lowercase letters in @enumerate; get a bigger
  1620.                   alphabet}%
  1621.     \fi
  1622.     \char\lccode\itemno
  1623.   }%
  1624. }
  1625.  
  1626. % The starting (uppercase) letter is in \thearg.
  1627. \def\uppercaseenumerate{%
  1628.   \itemno = \expandafter`\thearg
  1629.   \startenumeration{%
  1630.     % Be sure we're not beyond the end of the alphabet.
  1631.     \ifnum\itemno=0
  1632.       \errmessage{No more uppercase letters in @enumerate; get a bigger
  1633.                   alphabet}
  1634.     \fi
  1635.     \char\uccode\itemno
  1636.   }%
  1637. }
  1638.  
  1639. % Call itemizey, adding a period to the first argument and supplying the
  1640. % common last two arguments.  Also subtract one from the initial value in
  1641. % \itemno, since @item increments \itemno.
  1642. %
  1643. \def\startenumeration#1{%
  1644.   \advance\itemno by -1
  1645.   \itemizey{#1.}\Eenumerate\flushcr
  1646. }
  1647.  
  1648. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1649. % to @enumerate.
  1650. %
  1651. \def\alphaenumerate{\enumerate{a}}
  1652. \def\capsenumerate{\enumerate{A}}
  1653. \def\Ealphaenumerate{\Eenumerate}
  1654. \def\Ecapsenumerate{\Eenumerate}
  1655.  
  1656. % Definition of @item while inside @itemize.
  1657.  
  1658. \def\itemizeitem{%
  1659. \advance\itemno by 1
  1660. {\let\par=\endgraf \smallbreak}%
  1661. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  1662. {\parskip=0in \hskip 0pt
  1663. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1664. \vadjust{\penalty 1200}}%
  1665. \flushcr}
  1666.  
  1667. % @multitable macros
  1668. % Amy Hendrickson, 8/18/94
  1669. %
  1670. % @multitable ... @endmultitable will make as many columns as desired.
  1671. % Contents of each column will wrap at width given in preamble. Width
  1672. % can be specified either with sample text given in a template line,
  1673. % or in percent of \hsize, the current width of text on page.
  1674.  
  1675. % Table can continue over pages but will only break between lines.
  1676.  
  1677. % To make preamble:
  1678. %
  1679. % Either define widths of columns in terms of percent of \hsize: 
  1680. %   @multitable @percentofhsize .2 .3 .5
  1681. %   @item ...
  1682. %
  1683. %   Numbers following @percentofhsize are the percent of the total
  1684. %   current hsize to be used for each column. You may use as many
  1685. %   columns as desired.
  1686.  
  1687. % Or use a template:
  1688. %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
  1689. %   @item ...
  1690. %   using the widest term desired in each column.
  1691.  
  1692.  
  1693. % Each new table line starts with @item, each subsequent new column 
  1694. % starts with @tab. Empty columns may be produced by supplying @tab's
  1695. % with nothing between them for as many times as empty columns are needed,
  1696. % ie, @tab@tab@tab will produce two empty columns.
  1697.  
  1698. % @item, @tab, @multicolumn or @endmulticolumn do not need to be on their
  1699. % own lines, but it will not hurt if they are.
  1700.  
  1701. % Sample multitable:
  1702.  
  1703. %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
  1704. %   @item first col stuff @tab second col stuff @tab third col
  1705. %   @item 
  1706. %   first col stuff 
  1707. %   @tab 
  1708. %   second col stuff 
  1709. %   @tab 
  1710. %   third col 
  1711. %   @item first col stuff @tab second col stuff 
  1712. %   @tab Many paragraphs of text may be used in any column.
  1713. %     
  1714. %         They will wrap at the width determined by the template.
  1715. %   @item@tab@tab This will be in third column.
  1716. %   @endmultitable
  1717.  
  1718. % Default dimensions may be reset by user.
  1719. % @intableparskip will set vertical space between paragraphs in table.
  1720. % @intableparindent will set paragraph indent in table.
  1721. % @spacebetweencols will set horizontal space to be left between columns.
  1722. % @spacebetweenlines will set vertical space to be left between lines.
  1723.  
  1724. %%%%
  1725. % Dimensions 
  1726.  
  1727. \newdimen\intableparskip
  1728. \newdimen\intableparindent
  1729. \newdimen\spacebetweencols
  1730. \newdimen\spacebetweenlines
  1731. \intableparskip=0pt
  1732. \intableparindent=6pt
  1733. \spacebetweencols=12pt
  1734. \spacebetweenlines=12pt
  1735.  
  1736. %%%%
  1737. % Macros used to set up halign preamble:
  1738. \let\endsetuptable\relax
  1739. \def\xendsetuptable{\endsetuptable}
  1740. \let\percentofhsize\relax
  1741. \def\xpercentofhsize{\percentofhsize}
  1742. \newif\ifsetpercent
  1743.  
  1744. \newcount\colcount
  1745. \def\setuptable#1{\def\firstarg{#1}%
  1746. \ifx\firstarg\xendsetuptable\let\go\relax%
  1747. \else
  1748.   \ifx\firstarg\xpercentofhsize\global\setpercenttrue%
  1749.   \else
  1750.     \ifsetpercent
  1751.        \if#1.\else%
  1752.        \global\advance\colcount by1 %
  1753.        \expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}%
  1754.        \fi
  1755.     \else
  1756.        \global\advance\colcount by1
  1757.        \setbox0=\hbox{#1}%
  1758.        \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
  1759.     \fi%
  1760.   \fi%
  1761.   \let\go\setuptable%
  1762. \fi\go}
  1763. %%%%
  1764. % multitable syntax
  1765. \def\tab{&}
  1766.  
  1767. %%%%
  1768. % @multitable ... @endmultitable definitions:
  1769.  
  1770. \def\multitable#1\item{\bgroup
  1771. \let\item\cr
  1772. \tolerance=9500
  1773. \hbadness=9500
  1774. \parskip=\intableparskip
  1775. \parindent=\intableparindent
  1776. \overfullrule=0pt
  1777. \global\colcount=0\relax%
  1778. \def\Emultitable{\global\setpercentfalse\global\everycr{}\cr\egroup\egroup}%
  1779.  % To parse everything between @multitable and @item :
  1780. \def\one{#1}\expandafter\setuptable\one\endsetuptable
  1781.  % Need to reset this to 0 after \setuptable.
  1782. \global\colcount=0\relax% 
  1783.  %
  1784.  % This preamble sets up a generic column definition, which will
  1785.  % be used as many times as user calls for columns.
  1786.  % \vtop will set a single line and will also let text wrap and 
  1787.  % continue for many paragraphs if desired.
  1788. \halign\bgroup&\global\advance\colcount by 1\relax%
  1789. \vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
  1790.  % In order to keep entries from bumping into each other
  1791.  % we will add a \leftskip of \spacebetweencols to all columns after
  1792.  % the first one.
  1793.  %  If a template has been used, we will add \spacebetweencols 
  1794.  % to the width of each template entry.
  1795.  %  If user has set preamble in terms of percent of \hsize
  1796.  % we will use that dimension as the width of the column, and
  1797.  % the \leftskip will keep entries from bumping into each other.
  1798.  % Table will start at left margin and final column will justify at
  1799.  % right margin.
  1800. \ifnum\colcount=1
  1801. \else
  1802.   \ifsetpercent
  1803.   \else
  1804.    % If user has <not> set preamble in terms of percent of \hsize
  1805.    % we will advance \hsize by \spacebetweencols 
  1806.   \advance\hsize by \spacebetweencols
  1807.   \fi
  1808.  % In either case we will make \leftskip=\spacebetweencols:
  1809. \leftskip=\spacebetweencols
  1810. \fi
  1811. \noindent##}\cr%
  1812.  % \everycr will reset column counter, \colcount, at the end of
  1813.  % each line. Every column  entry will cause \colcount to advance by one. 
  1814.  % The table preamble
  1815.  % looks at the current \colcount to find the correct column width.
  1816. \global\everycr{\noalign{\nointerlineskip\vskip\spacebetweenlines
  1817. \filbreak%% keeps underfull box messages off when table breaks over pages.
  1818. \global\colcount=0\relax}}}
  1819.  
  1820. \message{indexing,}
  1821. % Index generation facilities
  1822.  
  1823. % Define \newwrite to be identical to plain tex's \newwrite
  1824. % except not \outer, so it can be used within \newindex.
  1825. {\catcode`\@=11
  1826. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  1827.  
  1828. % \newindex {foo} defines an index named foo.
  1829. % It automatically defines \fooindex such that
  1830. % \fooindex ...rest of line... puts an entry in the index foo.
  1831. % It also defines \fooindfile to be the number of the output channel for
  1832. % the file that    accumulates this index.  The file's extension is foo.
  1833. % The name of an index should be no more than 2 characters long
  1834. % for the sake of vms.
  1835.  
  1836. \def\newindex #1{
  1837. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1838. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1839. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1840. \noexpand\doindex {#1}}
  1841. }
  1842.  
  1843. % @defindex foo  ==  \newindex{foo}
  1844.  
  1845. \def\defindex{\parsearg\newindex}
  1846.  
  1847. % Define @defcodeindex, like @defindex except put all entries in @code.
  1848.  
  1849. \def\newcodeindex #1{
  1850. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1851. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1852. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1853. \noexpand\docodeindex {#1}}
  1854. }
  1855.  
  1856. \def\defcodeindex{\parsearg\newcodeindex}
  1857.  
  1858. % @synindex foo bar    makes index foo feed into index bar.
  1859. % Do this instead of @defindex foo if you don't want it as a separate index.
  1860. \def\synindex #1 #2 {%
  1861. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1862. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1863. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1864. \noexpand\doindex {#2}}%
  1865. }
  1866.  
  1867. % @syncodeindex foo bar   similar, but put all entries made for index foo
  1868. % inside @code.
  1869. \def\syncodeindex #1 #2 {%
  1870. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1871. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1872. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1873. \noexpand\docodeindex {#2}}%
  1874. }
  1875.  
  1876. % Define \doindex, the driver for all \fooindex macros.
  1877. % Argument #1 is generated by the calling \fooindex macro,
  1878. %  and it is "foo", the name of the index.
  1879.  
  1880. % \doindex just uses \parsearg; it calls \doind for the actual work.
  1881. % This is because \doind is more useful to call from other macros.
  1882.  
  1883. % There is also \dosubind {index}{topic}{subtopic}
  1884. % which makes an entry in a two-level index such as the operation index.
  1885.  
  1886. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  1887. \def\singleindexer #1{\doind{\indexname}{#1}}
  1888.  
  1889. % like the previous two, but they put @code around the argument.
  1890. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  1891. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  1892.  
  1893. \def\indexdummies{%
  1894. % Take care of the plain tex accent commands.
  1895. \def\"{\realbackslash "}%
  1896. \def\`{\realbackslash `}%
  1897. \def\'{\realbackslash '}%
  1898. \def\^{\realbackslash ^}%
  1899. \def\~{\realbackslash ~}%
  1900. \def\={\realbackslash =}%
  1901. \def\b{\realbackslash b}%
  1902. \def\c{\realbackslash c}%
  1903. \def\d{\realbackslash d}%
  1904. \def\u{\realbackslash u}%
  1905. \def\v{\realbackslash v}%
  1906. \def\H{\realbackslash H}%
  1907. % Take care of the plain tex special European modified letters.
  1908. \def\oe{\realbackslash oe}%
  1909. \def\ae{\realbackslash ae}%
  1910. \def\aa{\realbackslash aa}%
  1911. \def\OE{\realbackslash OE}%
  1912. \def\AE{\realbackslash AE}%
  1913. \def\AA{\realbackslash AA}%
  1914. \def\o{\realbackslash o}%
  1915. \def\O{\realbackslash O}%
  1916. \def\l{\realbackslash l}%
  1917. \def\L{\realbackslash L}%
  1918. \def\ss{\realbackslash ss}%
  1919. % Take care of texinfo commands likely to appear in an index entry.
  1920. \def\_{{\realbackslash _}}%
  1921. \def\w{\realbackslash w }%
  1922. \def\bf{\realbackslash bf }%
  1923. \def\rm{\realbackslash rm }%
  1924. \def\sl{\realbackslash sl }%
  1925. \def\sf{\realbackslash sf}%
  1926. \def\tt{\realbackslash tt}%
  1927. \def\gtr{\realbackslash gtr}%
  1928. \def\less{\realbackslash less}%
  1929. \def\hat{\realbackslash hat}%
  1930. \def\char{\realbackslash char}%
  1931. \def\TeX{\realbackslash TeX}%
  1932. \def\dots{\realbackslash dots }%
  1933. \def\copyright{\realbackslash copyright }%
  1934. \def\tclose##1{\realbackslash tclose {##1}}%
  1935. \def\code##1{\realbackslash code {##1}}%
  1936. \def\samp##1{\realbackslash samp {##1}}%
  1937. \def\t##1{\realbackslash r {##1}}%
  1938. \def\r##1{\realbackslash r {##1}}%
  1939. \def\i##1{\realbackslash i {##1}}%
  1940. \def\b##1{\realbackslash b {##1}}%
  1941. \def\cite##1{\realbackslash cite {##1}}%
  1942. \def\key##1{\realbackslash key {##1}}%
  1943. \def\file##1{\realbackslash file {##1}}%
  1944. \def\var##1{\realbackslash var {##1}}%
  1945. \def\kbd##1{\realbackslash kbd {##1}}%
  1946. \def\dfn##1{\realbackslash dfn {##1}}%
  1947. \def\emph##1{\realbackslash emph {##1}}%
  1948. }
  1949.  
  1950. % \indexnofonts no-ops all font-change commands.
  1951. % This is used when outputting the strings to sort the index by.
  1952. \def\indexdummyfont#1{#1}
  1953. \def\indexdummytex{TeX}
  1954. \def\indexdummydots{...}
  1955.  
  1956. \def\indexnofonts{%
  1957. % Just ignore accents.
  1958. \let\"=\indexdummyfont
  1959. \let\`=\indexdummyfont
  1960. \let\'=\indexdummyfont
  1961. \let\^=\indexdummyfont
  1962. \let\~=\indexdummyfont
  1963. \let\==\indexdummyfont
  1964. \let\b=\indexdummyfont
  1965. \let\c=\indexdummyfont
  1966. \let\d=\indexdummyfont
  1967. \let\u=\indexdummyfont
  1968. \let\v=\indexdummyfont
  1969. \let\H=\indexdummyfont
  1970. % Take care of the plain tex special European modified letters.
  1971. \def\oe{oe}%
  1972. \def\ae{ae}%
  1973. \def\aa{aa}%
  1974. \def\OE{OE}%
  1975. \def\AE{AE}%
  1976. \def\AA{AA}%
  1977. \def\o{o}%
  1978. \def\O{O}%
  1979. \def\l{l}%
  1980. \def\L{L}%
  1981. \def\ss{ss}%
  1982. \let\w=\indexdummyfont
  1983. \let\t=\indexdummyfont
  1984. \let\r=\indexdummyfont
  1985. \let\i=\indexdummyfont
  1986. \let\b=\indexdummyfont
  1987. \let\emph=\indexdummyfont
  1988. \let\strong=\indexdummyfont
  1989. \let\cite=\indexdummyfont
  1990. \let\sc=\indexdummyfont
  1991. %Don't no-op \tt, since it isn't a user-level command
  1992. % and is used in the definitions of the active chars like <, >, |...
  1993. %\let\tt=\indexdummyfont
  1994. \let\tclose=\indexdummyfont
  1995. \let\code=\indexdummyfont
  1996. \let\file=\indexdummyfont
  1997. \let\samp=\indexdummyfont
  1998. \let\kbd=\indexdummyfont
  1999. \let\key=\indexdummyfont
  2000. \let\var=\indexdummyfont
  2001. \let\TeX=\indexdummytex
  2002. \let\dots=\indexdummydots
  2003. }
  2004.  
  2005. % To define \realbackslash, we must make \ not be an escape.
  2006. % We must first make another character (@) an escape
  2007. % so we do not become unable to do a definition.
  2008.  
  2009. {\catcode`\@=0 \catcode`\\=\other
  2010. @gdef@realbackslash{\}}
  2011.  
  2012. \let\indexbackslash=0  %overridden during \printindex.
  2013.  
  2014. \def\doind #1#2{%
  2015. {\count10=\lastpenalty %
  2016. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  2017. \escapechar=`\\%
  2018. {\let\folio=0% Expand all macros now EXCEPT \folio
  2019. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  2020. % so it will be output as is; and it will print as backslash in the indx.
  2021. %
  2022. % Now process the index-string once, with all font commands turned off,
  2023. % to get the string to sort the index by.
  2024. {\indexnofonts
  2025. \xdef\temp1{#2}%
  2026. }%
  2027. % Now produce the complete index entry.  We process the index-string again,
  2028. % this time with font commands expanded, to get what to print in the index.
  2029. \edef\temp{%
  2030. \write \csname#1indfile\endcsname{%
  2031. \realbackslash entry {\temp1}{\folio}{#2}}}%
  2032. \temp }%
  2033. }\penalty\count10}}
  2034.  
  2035. \def\dosubind #1#2#3{%
  2036. {\count10=\lastpenalty %
  2037. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  2038. \escapechar=`\\%
  2039. {\let\folio=0%
  2040. \def\rawbackslashxx{\indexbackslash}%
  2041. %
  2042. % Now process the index-string once, with all font commands turned off,
  2043. % to get the string to sort the index by.
  2044. {\indexnofonts
  2045. \xdef\temp1{#2 #3}%
  2046. }%
  2047. % Now produce the complete index entry.  We process the index-string again,
  2048. % this time with font commands expanded, to get what to print in the index.
  2049. \edef\temp{%
  2050. \write \csname#1indfile\endcsname{%
  2051. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  2052. \temp }%
  2053. }\penalty\count10}}
  2054.  
  2055. % The index entry written in the file actually looks like
  2056. %  \entry {sortstring}{page}{topic}
  2057. % or
  2058. %  \entry {sortstring}{page}{topic}{subtopic}
  2059. % The texindex program reads in these files and writes files
  2060. % containing these kinds of lines:
  2061. %  \initial {c}
  2062. %     before the first topic whose initial is c
  2063. %  \entry {topic}{pagelist}
  2064. %     for a topic that is used without subtopics
  2065. %  \primary {topic}
  2066. %     for the beginning of a topic that is used with subtopics
  2067. %  \secondary {subtopic}{pagelist}
  2068. %     for each subtopic.
  2069.  
  2070. % Define the user-accessible indexing commands
  2071. % @findex, @vindex, @kindex, @cindex.
  2072.  
  2073. \def\findex {\fnindex}
  2074. \def\kindex {\kyindex}
  2075. \def\cindex {\cpindex}
  2076. \def\vindex {\vrindex}
  2077. \def\tindex {\tpindex}
  2078. \def\pindex {\pgindex}
  2079.  
  2080. \def\cindexsub {\begingroup\obeylines\cindexsub}
  2081. {\obeylines %
  2082. \gdef\cindexsub "#1" #2^^M{\endgroup %
  2083. \dosubind{cp}{#2}{#1}}}
  2084.  
  2085. % Define the macros used in formatting output of the sorted index material.
  2086.  
  2087. % This is what you call to cause a particular index to get printed.
  2088. % Write
  2089. % @unnumbered Function Index
  2090. % @printindex fn
  2091.  
  2092. \def\printindex{\parsearg\doprintindex}
  2093.  
  2094. \def\doprintindex#1{%
  2095.   \tex
  2096.   \dobreak \chapheadingskip {10000}
  2097.   \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  2098.   \catcode`\$=\other
  2099.   \catcode`\~=\other
  2100.   \indexbreaks
  2101.   %
  2102.   % The following don't help, since the chars were translated
  2103.   % when the raw index was written, and their fonts were discarded
  2104.   % due to \indexnofonts.
  2105.   %\catcode`\"=\active
  2106.   %\catcode`\^=\active
  2107.   %\catcode`\_=\active
  2108.   %\catcode`\|=\active
  2109.   %\catcode`\<=\active
  2110.   %\catcode`\>=\active
  2111.   % %
  2112.   \def\indexbackslash{\rawbackslashxx}
  2113.   \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  2114.   \begindoublecolumns
  2115.   %
  2116.   % See if the index file exists and is nonempty.
  2117.   \openin 1 \jobname.#1s
  2118.   \ifeof 1
  2119.     % \enddoublecolumns gets confused if there is no text in the index,
  2120.     % and it loses the chapter title and the aux file entries for the
  2121.     % index.  The easiest way to prevent this problem is to make sure
  2122.     % there is some text.
  2123.     (Index is nonexistent)
  2124.     \else
  2125.     %
  2126.     % If the index file exists but is empty, then \openin leaves \ifeof
  2127.     % false.  We have to make TeX try to read something from the file, so
  2128.     % it can discover if there is anything in it.
  2129.     \read 1 to \temp
  2130.     \ifeof 1
  2131.       (Index is empty)
  2132.     \else
  2133.       \input \jobname.#1s
  2134.     \fi
  2135.   \fi
  2136.   \closein 1
  2137.   \enddoublecolumns
  2138.   \Etex
  2139. }
  2140.  
  2141. % These macros are used by the sorted index file itself.
  2142. % Change them to control the appearance of the index.
  2143.  
  2144. % Same as \bigskipamount except no shrink.
  2145. % \balancecolumns gets confused if there is any shrink.
  2146. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  2147.  
  2148. \def\initial #1{%
  2149. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  2150. \ifdim\lastskip<\initialskipamount
  2151. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  2152. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  2153.  
  2154. % This typesets a paragraph consisting of #1, dot leaders, and then #2
  2155. % flush to the right margin.  It is used for index and table of contents
  2156. % entries.  The paragraph is indented by \leftskip.
  2157. %
  2158. \def\entry #1#2{\begingroup
  2159.   %
  2160.   % Start a new paragraph if necessary, so our assignments below can't
  2161.   % affect previous text.
  2162.   \par
  2163.   %
  2164.   % Do not fill out the last line with white space.
  2165.   \parfillskip = 0in
  2166.   %
  2167.   % No extra space above this paragraph.
  2168.   \parskip = 0in
  2169.   %
  2170.   % Do not prefer a separate line ending with a hyphen to fewer lines.
  2171.   \finalhyphendemerits = 0
  2172.   %
  2173.   % \hangindent is only relevant when the entry text and page number
  2174.   % don't both fit on one line.  In that case, bob suggests starting the
  2175.   % dots pretty far over on the line.  Unfortunately, a large
  2176.   % indentation looks wrong when the entry text itself is broken across
  2177.   % lines.  So we use a small indentation and put up with long leaders.
  2178.   %
  2179.   % \hangafter is reset to 1 (which is the value we want) at the start
  2180.   % of each paragraph, so we need not do anything with that.
  2181.   \hangindent=2em
  2182.   %
  2183.   % When the entry text needs to be broken, just fill out the first line
  2184.   % with blank space.
  2185.   \rightskip = 0pt plus1fil
  2186.   %
  2187.   % Start a ``paragraph'' for the index entry so the line breaking
  2188.   % parameters we've set above will have an effect.
  2189.   \noindent
  2190.   %
  2191.   % Insert the text of the index entry.  TeX will do line-breaking on it.
  2192.   #1%
  2193.   % The following is kluged to not output a line of dots in the index if
  2194.   % there are no page numbers.  The next person who breaks this will be
  2195.   % cursed by a Unix daemon.
  2196.   \def\tempa{{\rm }}%
  2197.   \def\tempb{#2}%
  2198.   \edef\tempc{\tempa}%
  2199.   \edef\tempd{\tempb}%
  2200.   \ifx\tempc\tempd\ \else%
  2201.     %
  2202.     % If we must, put the page number on a line of its own, and fill out
  2203.     % this line with blank space.  (The \hfil is overwhelmed with the
  2204.     % fill leaders glue in \indexdotfill if the page number does fit.)
  2205.     \hfil\penalty50
  2206.     \null\nobreak\indexdotfill % Have leaders before the page number.
  2207.     %
  2208.     % The `\ ' here is removed by the implicit \unskip that TeX does as
  2209.     % part of (the primitive) \par.  Without it, a spurious underfull
  2210.     % \hbox ensues.
  2211.     \ #2% The page number ends the paragraph.
  2212.   \fi%
  2213.   \par
  2214. \endgroup}
  2215.  
  2216. % Like \dotfill except takes at least 1 em.
  2217. \def\indexdotfill{\cleaders
  2218.   \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
  2219.  
  2220. \def\primary #1{\line{#1\hfil}}
  2221.  
  2222. \newskip\secondaryindent \secondaryindent=0.5cm
  2223.  
  2224. \def\secondary #1#2{
  2225. {\parfillskip=0in \parskip=0in
  2226. \hangindent =1in \hangafter=1
  2227. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  2228. }}
  2229.  
  2230. %% Define two-column mode, which is used in indexes.
  2231. %% Adapted from the TeXbook, page 416.
  2232. \catcode `\@=11
  2233.  
  2234. \newbox\partialpage
  2235.  
  2236. \newdimen\doublecolumnhsize
  2237.  
  2238. \def\begindoublecolumns{\begingroup
  2239.   % Grab any single-column material above us.
  2240.   \output = {\global\setbox\partialpage
  2241.     =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}%
  2242.   \eject
  2243.   %
  2244.   % Now switch to the double-column output routine.
  2245.   \output={\doublecolumnout}%
  2246.   %
  2247.   % Change the page size parameters.  We could do this once outside this
  2248.   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  2249.   % format, but then we repeat the same computation.  Repeating a couple
  2250.   % of assignments once per index is clearly meaningless for the
  2251.   % execution time, so we may as well do it once.
  2252.   %
  2253.   % First we halve the line length, less a little for the gutter between
  2254.   % the columns.  We compute the gutter based on the line length, so it
  2255.   % changes automatically with the paper format.  The magic constant
  2256.   % below is chosen so that the gutter has the same value (well, +- <
  2257.   % 1pt) as it did when we hard-coded it.
  2258.   %
  2259.   % We put the result in a separate register, \doublecolumhsize, so we
  2260.   % can restore it in \pagesofar, after \hsize itself has (potentially)
  2261.   % been clobbered.
  2262.   %
  2263.   \doublecolumnhsize = \hsize
  2264.     \advance\doublecolumnhsize by -.04154\hsize
  2265.     \divide\doublecolumnhsize by 2
  2266.   \hsize = \doublecolumnhsize
  2267.   %
  2268.   % Double the \vsize as well.  (We don't need a separate register here,
  2269.   % since nobody clobbers \vsize.)
  2270.   \vsize = 2\vsize
  2271.   \doublecolumnpagegoal
  2272. }
  2273.  
  2274. \def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage}
  2275.  
  2276. \def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  2277.   \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage
  2278.   \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1}
  2279.   \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3}
  2280.   \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  2281.   \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  2282. }
  2283. \def\doublecolumnpagegoal{%
  2284.   \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@
  2285. }
  2286. \def\pagesofar{\unvbox\partialpage %
  2287.   \hsize=\doublecolumnhsize % have to restore this since output routine
  2288.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  2289. \def\doublecolumnout{%
  2290.   \setbox5=\copy255
  2291.   {\vbadness=10000 \doublecolumnsplit}
  2292.   \ifvbox255
  2293.     \setbox0=\vtop to\dimen@{\unvbox0}
  2294.     \setbox2=\vtop to\dimen@{\unvbox2}
  2295.     \onepageout\pagesofar \unvbox255 \penalty\outputpenalty
  2296.   \else
  2297.     \setbox0=\vbox{\unvbox5}
  2298.     \ifvbox0
  2299.       \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  2300.       \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth
  2301.       {\vbadness=10000
  2302.     \loop \global\setbox5=\copy0
  2303.           \setbox1=\vsplit5 to\dimen@
  2304.           \setbox3=\vsplit5 to\dimen@
  2305.           \ifvbox5 \global\advance\dimen@ by1pt \repeat
  2306.         \setbox0=\vbox to\dimen@{\unvbox1}
  2307.         \setbox2=\vbox to\dimen@{\unvbox3}
  2308.         \global\setbox\partialpage=\vbox{\pagesofar}
  2309.         \doublecolumnpagegoal
  2310.       }
  2311.     \fi
  2312.   \fi
  2313. }
  2314.  
  2315. \catcode `\@=\other
  2316. \message{sectioning,}
  2317. % Define chapters, sections, etc.
  2318.  
  2319. \newcount \chapno
  2320. \newcount \secno        \secno=0
  2321. \newcount \subsecno     \subsecno=0
  2322. \newcount \subsubsecno  \subsubsecno=0
  2323.  
  2324. % This counter is funny since it counts through charcodes of letters A, B, ...
  2325. \newcount \appendixno  \appendixno = `\@
  2326. \def\appendixletter{\char\the\appendixno}
  2327.  
  2328. \newwrite \contentsfile
  2329. % This is called from \setfilename.
  2330. \def\opencontents{\openout \contentsfile = \jobname.toc}
  2331.  
  2332. % Each @chapter defines this as the name of the chapter.
  2333. % page headings and footings can use it.  @section does likewise
  2334.  
  2335. \def\thischapter{} \def\thissection{}
  2336. \def\seccheck#1{\if \pageno<0 %
  2337. \errmessage{@#1 not allowed after generating table of contents}\fi
  2338. %
  2339. }
  2340.  
  2341. \def\chapternofonts{%
  2342. \let\rawbackslash=\relax%
  2343. \let\frenchspacing=\relax%
  2344. \def\result{\realbackslash result}
  2345. \def\equiv{\realbackslash equiv}
  2346. \def\expansion{\realbackslash expansion}
  2347. \def\print{\realbackslash print}
  2348. \def\TeX{\realbackslash TeX}
  2349. \def\dots{\realbackslash dots}
  2350. \def\copyright{\realbackslash copyright}
  2351. \def\tt{\realbackslash tt}
  2352. \def\bf{\realbackslash bf }
  2353. \def\w{\realbackslash w}
  2354. \def\less{\realbackslash less}
  2355. \def\gtr{\realbackslash gtr}
  2356. \def\hat{\realbackslash hat}
  2357. \def\char{\realbackslash char}
  2358. \def\tclose##1{\realbackslash tclose {##1}}
  2359. \def\code##1{\realbackslash code {##1}}
  2360. \def\samp##1{\realbackslash samp {##1}}
  2361. \def\r##1{\realbackslash r {##1}}
  2362. \def\b##1{\realbackslash b {##1}}
  2363. \def\key##1{\realbackslash key {##1}}
  2364. \def\file##1{\realbackslash file {##1}}
  2365. \def\kbd##1{\realbackslash kbd {##1}}
  2366. % These are redefined because @smartitalic wouldn't work inside xdef.
  2367. \def\i##1{\realbackslash i {##1}}
  2368. \def\cite##1{\realbackslash cite {##1}}
  2369. \def\var##1{\realbackslash var {##1}}
  2370. \def\emph##1{\realbackslash emph {##1}}
  2371. \def\dfn##1{\realbackslash dfn {##1}}
  2372. }
  2373.  
  2374. \newcount\absseclevel % used to calculate proper heading level
  2375. \newcount\secbase\secbase=0 % @raise/lowersections modify this count
  2376.  
  2377. % @raisesections: treat @section as chapter, @subsection as section, etc.
  2378. \def\raisesections{\global\advance\secbase by -1}
  2379. \let\up=\raisesections % original BFox name
  2380.  
  2381. % @lowersections: treat @chapter as section, @section as subsection, etc.
  2382. \def\lowersections{\global\advance\secbase by 1}
  2383. \let\down=\lowersections % original BFox name
  2384.  
  2385. % Choose a numbered-heading macro
  2386. % #1 is heading level if unmodified by @raisesections or @lowersections
  2387. % #2 is text for heading
  2388. \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  2389. \ifcase\absseclevel
  2390.   \chapterzzz{#2}
  2391. \or
  2392.   \seczzz{#2}
  2393. \or
  2394.   \numberedsubseczzz{#2}
  2395. \or
  2396.   \numberedsubsubseczzz{#2}
  2397. \else
  2398.   \ifnum \absseclevel<0
  2399.     \chapterzzz{#2}
  2400.   \else
  2401.     \numberedsubsubseczzz{#2}
  2402.   \fi
  2403. \fi
  2404. }
  2405.  
  2406. % like \numhead, but chooses appendix heading levels
  2407. \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  2408. \ifcase\absseclevel
  2409.   \appendixzzz{#2}
  2410. \or
  2411.   \appendixsectionzzz{#2}
  2412. \or
  2413.   \appendixsubseczzz{#2}
  2414. \or
  2415.   \appendixsubsubseczzz{#2}
  2416. \else
  2417.   \ifnum \absseclevel<0
  2418.     \appendixzzz{#2}
  2419.   \else
  2420.     \appendixsubsubseczzz{#2}
  2421.   \fi
  2422. \fi
  2423. }
  2424.  
  2425. % like \numhead, but chooses numberless heading levels
  2426. \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  2427. \ifcase\absseclevel
  2428.   \unnumberedzzz{#2}
  2429. \or
  2430.   \unnumberedseczzz{#2}
  2431. \or
  2432.   \unnumberedsubseczzz{#2}
  2433. \or
  2434.   \unnumberedsubsubseczzz{#2}
  2435. \else
  2436.   \ifnum \absseclevel<0
  2437.     \unnumberedzzz{#2}
  2438.   \else
  2439.     \unnumberedsubsubseczzz{#2}
  2440.   \fi
  2441. \fi
  2442. }
  2443.  
  2444.  
  2445. \def\thischaptername{No Chapter Title}
  2446. \outer\def\chapter{\parsearg\chapteryyy}
  2447. \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
  2448. \def\chapterzzz #1{\seccheck{chapter}%
  2449. \secno=0 \subsecno=0 \subsubsecno=0
  2450. \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  2451. \chapmacro {#1}{\the\chapno}%
  2452. \gdef\thissection{#1}%
  2453. \gdef\thischaptername{#1}%
  2454. % We don't substitute the actual chapter name into \thischapter
  2455. % because we don't want its macros evaluated now.
  2456. \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
  2457. {\chapternofonts%
  2458. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  2459. \escapechar=`\\%
  2460. \write \contentsfile \temp  %
  2461. \donoderef %
  2462. \global\let\section = \numberedsec
  2463. \global\let\subsection = \numberedsubsec
  2464. \global\let\subsubsection = \numberedsubsubsec
  2465. }}
  2466.  
  2467. \outer\def\appendix{\parsearg\appendixyyy}
  2468. \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
  2469. \def\appendixzzz #1{\seccheck{appendix}%
  2470. \secno=0 \subsecno=0 \subsubsecno=0
  2471. \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  2472. \chapmacro {#1}{\putwordAppendix{} \appendixletter}%
  2473. \gdef\thissection{#1}%
  2474. \gdef\thischaptername{#1}%
  2475. \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
  2476. {\chapternofonts%
  2477. \edef\temp{{\realbackslash chapentry
  2478.   {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}%
  2479. \escapechar=`\\%
  2480. \write \contentsfile \temp  %
  2481. \appendixnoderef %
  2482. \global\let\section = \appendixsec
  2483. \global\let\subsection = \appendixsubsec
  2484. \global\let\subsubsection = \appendixsubsubsec
  2485. }}
  2486.  
  2487. \outer\def\top{\parsearg\unnumberedyyy}
  2488. \outer\def\unnumbered{\parsearg\unnumberedyyy}
  2489. \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
  2490. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  2491. \secno=0 \subsecno=0 \subsubsecno=0
  2492. %
  2493. % This used to be simply \message{#1}, but TeX fully expands the
  2494. % argument to \message.  Therefore, if #1 contained @-commands, TeX
  2495. % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
  2496. % expanded @cite (which turns out to cause errors because \cite is meant
  2497. % to be executed, not expanded).
  2498. %
  2499. % Anyway, we don't want the fully-expanded definition of @cite to appear
  2500. % as a result of the \message, we just want `@cite' itself.  We use
  2501. % \the<toks register> to achieve this: TeX expands \the<toks> only once,
  2502. % simply yielding the contents of the <toks register>.
  2503. \toks0 = {#1}\message{(\the\toks0)}%
  2504. %
  2505. \unnumbchapmacro {#1}%
  2506. \gdef\thischapter{#1}\gdef\thissection{#1}%
  2507. {\chapternofonts%
  2508. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  2509. \escapechar=`\\%
  2510. \write \contentsfile \temp  %
  2511. \unnumbnoderef %
  2512. \global\let\section = \unnumberedsec
  2513. \global\let\subsection = \unnumberedsubsec
  2514. \global\let\subsubsection = \unnumberedsubsubsec
  2515. }}
  2516.  
  2517. \outer\def\numberedsec{\parsearg\secyyy}
  2518. \def\secyyy #1{\numhead1{#1}} % normally calls seczzz
  2519. \def\seczzz #1{\seccheck{section}%
  2520. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  2521. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  2522. {\chapternofonts%
  2523. \edef\temp{{\realbackslash secentry %
  2524. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  2525. \escapechar=`\\%
  2526. \write \contentsfile \temp %
  2527. \donoderef %
  2528. \penalty 10000 %
  2529. }}
  2530.  
  2531. \outer\def\appenixsection{\parsearg\appendixsecyyy}
  2532. \outer\def\appendixsec{\parsearg\appendixsecyyy}
  2533. \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
  2534. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  2535. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  2536. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  2537. {\chapternofonts%
  2538. \edef\temp{{\realbackslash secentry %
  2539. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  2540. \escapechar=`\\%
  2541. \write \contentsfile \temp %
  2542. \appendixnoderef %
  2543. \penalty 10000 %
  2544. }}
  2545.  
  2546. \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
  2547. \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
  2548. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  2549. \plainsecheading {#1}\gdef\thissection{#1}%
  2550. {\chapternofonts%
  2551. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  2552. \escapechar=`\\%
  2553. \write \contentsfile \temp %
  2554. \unnumbnoderef %
  2555. \penalty 10000 %
  2556. }}
  2557.  
  2558. \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
  2559. \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
  2560. \def\numberedsubseczzz #1{\seccheck{subsection}%
  2561. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  2562. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  2563. {\chapternofonts%
  2564. \edef\temp{{\realbackslash subsecentry %
  2565. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  2566. \escapechar=`\\%
  2567. \write \contentsfile \temp %
  2568. \donoderef %
  2569. \penalty 10000 %
  2570. }}
  2571.  
  2572. \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
  2573. \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
  2574. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  2575. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  2576. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  2577. {\chapternofonts%
  2578. \edef\temp{{\realbackslash subsecentry %
  2579. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  2580. \escapechar=`\\%
  2581. \write \contentsfile \temp %
  2582. \appendixnoderef %
  2583. \penalty 10000 %
  2584. }}
  2585.  
  2586. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
  2587. \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
  2588. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  2589. \plainsecheading {#1}\gdef\thissection{#1}%
  2590. {\chapternofonts%
  2591. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  2592. \escapechar=`\\%
  2593. \write \contentsfile \temp %
  2594. \unnumbnoderef %
  2595. \penalty 10000 %
  2596. }}
  2597.  
  2598. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
  2599. \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
  2600. \def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
  2601. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  2602. \subsubsecheading {#1}
  2603.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  2604. {\chapternofonts%
  2605. \edef\temp{{\realbackslash subsubsecentry %
  2606.   {#1}
  2607.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
  2608.   {\noexpand\folio}}}%
  2609. \escapechar=`\\%
  2610. \write \contentsfile \temp %
  2611. \donoderef %
  2612. \penalty 10000 %
  2613. }}
  2614.  
  2615. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
  2616. \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
  2617. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  2618. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  2619. \subsubsecheading {#1}
  2620.   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  2621. {\chapternofonts%
  2622. \edef\temp{{\realbackslash subsubsecentry{#1}%
  2623.   {\appendixletter}
  2624.   {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
  2625. \escapechar=`\\%
  2626. \write \contentsfile \temp %
  2627. \appendixnoderef %
  2628. \penalty 10000 %
  2629. }}
  2630.  
  2631. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
  2632. \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
  2633. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  2634. \plainsecheading {#1}\gdef\thissection{#1}%
  2635. {\chapternofonts%
  2636. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  2637. \escapechar=`\\%
  2638. \write \contentsfile \temp %
  2639. \unnumbnoderef %
  2640. \penalty 10000 %
  2641. }}
  2642.  
  2643. % These are variants which are not "outer", so they can appear in @ifinfo.
  2644. % Actually, they should now be obsolete; ordinary section commands should work.
  2645. \def\infotop{\parsearg\unnumberedzzz}
  2646. \def\infounnumbered{\parsearg\unnumberedzzz}
  2647. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  2648. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  2649. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  2650.  
  2651. \def\infoappendix{\parsearg\appendixzzz}
  2652. \def\infoappendixsec{\parsearg\appendixseczzz}
  2653. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  2654. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  2655.  
  2656. \def\infochapter{\parsearg\chapterzzz}
  2657. \def\infosection{\parsearg\sectionzzz}
  2658. \def\infosubsection{\parsearg\subsectionzzz}
  2659. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  2660.  
  2661. % These macros control what the section commands do, according
  2662. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  2663. % Define them by default for a numbered chapter.
  2664. \global\let\section = \numberedsec
  2665. \global\let\subsection = \numberedsubsec
  2666. \global\let\subsubsection = \numberedsubsubsec
  2667.  
  2668. % Define @majorheading, @heading and @subheading
  2669.  
  2670. % NOTE on use of \vbox for chapter headings, section headings, and
  2671. % such:
  2672. %    1) We use \vbox rather than the earlier \line to permit
  2673. %       overlong headings to fold.
  2674. %    2) \hyphenpenalty is set to 10000 because hyphenation in a
  2675. %       heading is obnoxious; this forbids it.
  2676. %       3) Likewise, headings look best if no \parindent is used, and
  2677. %          if justification is not attempted.  Hence \raggedright.
  2678.  
  2679.  
  2680. \def\majorheading{\parsearg\majorheadingzzz}
  2681. \def\majorheadingzzz #1{%
  2682. {\advance\chapheadingskip by 10pt \chapbreak }%
  2683. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2684.                   \parindent=0pt\raggedright
  2685.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  2686.  
  2687. \def\chapheading{\parsearg\chapheadingzzz}
  2688. \def\chapheadingzzz #1{\chapbreak %
  2689. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2690.                   \parindent=0pt\raggedright
  2691.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  2692.  
  2693. \def\heading{\parsearg\secheadingi}
  2694.  
  2695. \def\subheading{\parsearg\subsecheadingi}
  2696.  
  2697. \def\subsubheading{\parsearg\subsubsecheadingi}
  2698.  
  2699. % These macros generate a chapter, section, etc. heading only
  2700. % (including whitespace, linebreaking, etc. around it),
  2701. % given all the information in convenient, parsed form.
  2702.  
  2703. %%% Args are the skip and penalty (usually negative)
  2704. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  2705.  
  2706. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  2707.  
  2708. %%% Define plain chapter starts, and page on/off switching for it
  2709. % Parameter controlling skip before chapter headings (if needed)
  2710.  
  2711. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  2712.  
  2713. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  2714. \def\chappager{\par\vfill\supereject}
  2715. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  2716.  
  2717. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  2718.  
  2719. \def\CHAPPAGoff{
  2720. \global\let\pchapsepmacro=\chapbreak
  2721. \global\let\pagealignmacro=\chappager}
  2722.  
  2723. \def\CHAPPAGon{
  2724. \global\let\pchapsepmacro=\chappager
  2725. \global\let\pagealignmacro=\chappager
  2726. \global\def\HEADINGSon{\HEADINGSsingle}}
  2727.  
  2728. \def\CHAPPAGodd{
  2729. \global\let\pchapsepmacro=\chapoddpage
  2730. \global\let\pagealignmacro=\chapoddpage
  2731. \global\def\HEADINGSon{\HEADINGSdouble}}
  2732.  
  2733. \CHAPPAGon
  2734.  
  2735. \def\CHAPFplain{
  2736. \global\let\chapmacro=\chfplain
  2737. \global\let\unnumbchapmacro=\unnchfplain}
  2738.  
  2739. \def\chfplain #1#2{%
  2740.   \pchapsepmacro
  2741.   {%
  2742.     \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2743.                      \parindent=0pt\raggedright
  2744.                      \rm #2\enspace #1}%
  2745.   }%
  2746.   \bigskip
  2747.   \penalty5000
  2748. }
  2749.  
  2750. \def\unnchfplain #1{%
  2751. \pchapsepmacro %
  2752. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2753.                   \parindent=0pt\raggedright
  2754.                   \rm #1\hfill}}\bigskip \par\penalty 10000 %
  2755. }
  2756. \CHAPFplain % The default
  2757.  
  2758. \def\unnchfopen #1{%
  2759. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2760.                        \parindent=0pt\raggedright
  2761.                        \rm #1\hfill}}\bigskip \par\penalty 10000 %
  2762. }
  2763.  
  2764. \def\chfopen #1#2{\chapoddpage {\chapfonts
  2765. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  2766. \par\penalty 5000 %
  2767. }
  2768.  
  2769. \def\CHAPFopen{
  2770. \global\let\chapmacro=\chfopen
  2771. \global\let\unnumbchapmacro=\unnchfopen}
  2772.  
  2773. % Parameter controlling skip before section headings.
  2774.  
  2775. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  2776. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  2777.  
  2778. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  2779. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  2780.  
  2781. % @paragraphindent  is defined for the Info formatting commands only.
  2782. \let\paragraphindent=\comment
  2783.  
  2784. % Section fonts are the base font at magstep2, which produces
  2785. % a size a bit more than 14 points in the default situation.
  2786.  
  2787. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  2788. \def\plainsecheading #1{\secheadingi {#1}}
  2789. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  2790. \secheadingbreak}%
  2791. {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2792.                  \parindent=0pt\raggedright
  2793.                  \rm #1\hfill}}%
  2794. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2795.  
  2796.  
  2797. % Subsection fonts are the base font at magstep1,
  2798. % which produces a size of 12 points.
  2799.  
  2800. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
  2801. \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2802. \subsecheadingbreak}%
  2803. {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2804.                      \parindent=0pt\raggedright
  2805.                      \rm #1\hfill}}%
  2806. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2807.  
  2808. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  2809.                   % Perhaps make sssec fonts scaled
  2810.                   % magstep half
  2811. \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
  2812. \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2813. \subsecheadingbreak}%
  2814. {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2815.                        \parindent=0pt\raggedright
  2816.                        \rm #1\hfill}}%
  2817. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  2818.  
  2819.  
  2820. \message{toc printing,}
  2821.  
  2822. % Finish up the main text and prepare to read what we've written
  2823. % to \contentsfile.
  2824.  
  2825. \newskip\contentsrightmargin \contentsrightmargin=1in
  2826. \def\startcontents#1{%
  2827.    \pagealignmacro
  2828.    \immediate\closeout \contentsfile
  2829.    \ifnum \pageno>0
  2830.       \pageno = -1        % Request roman numbered pages.
  2831.    \fi
  2832.    % Don't need to put `Contents' or `Short Contents' in the headline.
  2833.    % It is abundantly clear what they are.
  2834.    \unnumbchapmacro{#1}\def\thischapter{}%
  2835.    \begingroup           % Set up to handle contents files properly.
  2836.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  2837.       \raggedbottom             % Worry more about breakpoints than the bottom.
  2838.       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  2839. }
  2840.  
  2841.  
  2842. % Normal (long) toc.
  2843. \outer\def\contents{%
  2844.    \startcontents{\putwordTableofContents}%
  2845.       \input \jobname.toc
  2846.    \endgroup
  2847.    \vfill \eject
  2848. }
  2849.  
  2850. % And just the chapters.
  2851. \outer\def\summarycontents{%
  2852.    \startcontents{\putwordShortContents}%
  2853.       %
  2854.       \let\chapentry = \shortchapentry
  2855.       \let\unnumbchapentry = \shortunnumberedentry
  2856.       % We want a true roman here for the page numbers.
  2857.       \secfonts
  2858.       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  2859.       \rm
  2860.       \advance\baselineskip by 1pt % Open it up a little.
  2861.       \def\secentry ##1##2##3##4{}
  2862.       \def\unnumbsecentry ##1##2{}
  2863.       \def\subsecentry ##1##2##3##4##5{}
  2864.       \def\unnumbsubsecentry ##1##2{}
  2865.       \def\subsubsecentry ##1##2##3##4##5##6{}
  2866.       \def\unnumbsubsubsecentry ##1##2{}
  2867.       \input \jobname.toc
  2868.    \endgroup
  2869.    \vfill \eject
  2870. }
  2871. \let\shortcontents = \summarycontents
  2872.  
  2873. % These macros generate individual entries in the table of contents.
  2874. % The first argument is the chapter or section name.
  2875. % The last argument is the page number.
  2876. % The arguments in between are the chapter number, section number, ...
  2877.  
  2878. % Chapter-level things, for both the long and short contents.
  2879. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  2880.  
  2881. % See comments in \dochapentry re vbox and related settings
  2882. \def\shortchapentry#1#2#3{%
  2883.   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
  2884. }
  2885.  
  2886. % Typeset the label for a chapter or appendix for the short contents.
  2887. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  2888. % We could simplify the code here by writing out an \appendixentry
  2889. % command in the toc file for appendices, instead of using \chapentry
  2890. % for both, but it doesn't seem worth it.
  2891. \setbox0 = \hbox{\shortcontrm \putwordAppendix }
  2892. \newdimen\shortappendixwidth \shortappendixwidth = \wd0
  2893.  
  2894. \def\shortchaplabel#1{%
  2895.   % We typeset #1 in a box of constant width, regardless of the text of
  2896.   % #1, so the chapter titles will come out aligned.
  2897.   \setbox0 = \hbox{#1}%
  2898.   \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  2899.   %
  2900.   % This space should be plenty, since a single number is .5em, and the
  2901.   % widest letter (M) is 1em, at least in the Computer Modern fonts.
  2902.   % (This space doesn't include the extra space that gets added after
  2903.   % the label; that gets put in in \shortchapentry above.)
  2904.   \advance\dimen0 by 1.1em
  2905.   \hbox to \dimen0{#1\hfil}%
  2906. }
  2907.  
  2908. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  2909. \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
  2910.  
  2911. % Sections.
  2912. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  2913. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  2914.  
  2915. % Subsections.
  2916. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  2917. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  2918.  
  2919. % And subsubsections.
  2920. \def\subsubsecentry#1#2#3#4#5#6{%
  2921.   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  2922. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  2923.  
  2924.  
  2925. % This parameter controls the indentation of the various levels.
  2926. \newdimen\tocindent \tocindent = 3pc
  2927.  
  2928. % Now for the actual typesetting. In all these, #1 is the text and #2 is the
  2929. % page number.
  2930. %
  2931. % If the toc has to be broken over pages, we would want to be at chapters
  2932. % if at all possible; hence the \penalty.
  2933. \def\dochapentry#1#2{%
  2934.    \penalty-300 \vskip\baselineskip
  2935.    \begingroup
  2936.      \chapentryfonts
  2937.      \tocentry{#1}{\dopageno{#2}}%
  2938.    \endgroup
  2939.    \nobreak\vskip .25\baselineskip
  2940. }
  2941.  
  2942. \def\dosecentry#1#2{\begingroup
  2943.   \secentryfonts \leftskip=\tocindent
  2944.   \tocentry{#1}{\dopageno{#2}}%
  2945. \endgroup}
  2946.  
  2947. \def\dosubsecentry#1#2{\begingroup
  2948.   \subsecentryfonts \leftskip=2\tocindent
  2949.   \tocentry{#1}{\dopageno{#2}}%
  2950. \endgroup}
  2951.  
  2952. \def\dosubsubsecentry#1#2{\begingroup
  2953.   \subsubsecentryfonts \leftskip=3\tocindent
  2954.   \tocentry{#1}{\dopageno{#2}}%
  2955. \endgroup}
  2956.  
  2957. % Final typesetting of a toc entry; we use the same \entry macro as for
  2958. % the index entries, but we want to suppress hyphenation here.  (We
  2959. % can't do that in the \entry macro, since index entries might consist
  2960. % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
  2961. %
  2962. \def\tocentry#1#2{\begingroup
  2963.   \hyphenpenalty = 10000
  2964.   \entry{#1}{#2}%
  2965. \endgroup}
  2966.  
  2967. % Space between chapter (or whatever) number and the title.
  2968. \def\labelspace{\hskip1em \relax}
  2969.  
  2970. \def\dopageno#1{{\rm #1}}
  2971. \def\doshortpageno#1{{\rm #1}}
  2972.  
  2973. \def\chapentryfonts{\secfonts \rm}
  2974. \def\secentryfonts{\textfonts}
  2975. \let\subsecentryfonts = \textfonts
  2976. \let\subsubsecentryfonts = \textfonts
  2977.  
  2978.  
  2979. \message{environments,}
  2980.  
  2981. % Since these characters are used in examples, it should be an even number of
  2982. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  2983. % Furthermore, these definitions must come after we define our fonts.
  2984. \newbox\dblarrowbox    \newbox\longdblarrowbox
  2985. \newbox\pushcharbox    \newbox\bullbox
  2986. \newbox\equivbox       \newbox\errorbox
  2987.  
  2988. \let\ptexequiv = \equiv
  2989.  
  2990. %{\tentt
  2991. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  2992. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  2993. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  2994. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  2995. % Adapted from the manmac format (p.420 of TeXbook)
  2996. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  2997. %                                      depth .1ex\hfil}
  2998. %}
  2999.  
  3000. \def\point{$\star$}
  3001.  
  3002. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  3003. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  3004. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  3005.  
  3006. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  3007.  
  3008. % Adapted from the TeXbook's \boxit.
  3009. {\tentt \global\dimen0 = 3em}% Width of the box.
  3010. \dimen2 = .55pt % Thickness of rules
  3011. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  3012. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  3013.  
  3014. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  3015.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  3016.    \advance\hsize by -2\dimen2 % Rules.
  3017.    \vbox{
  3018.       \hrule height\dimen2
  3019.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  3020.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  3021.          \kern3pt\vrule width\dimen2}% Space to right.
  3022.       \hrule height\dimen2}
  3023.     \hfil}
  3024.  
  3025. % The @error{} command.
  3026. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  3027.  
  3028. % @tex ... @end tex    escapes into raw Tex temporarily.
  3029. % One exception: @ is still an escape character, so that @end tex works.
  3030. % But \@ or @@ will get a plain tex @ character.
  3031.  
  3032. \def\tex{\begingroup
  3033. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  3034. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  3035. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  3036. \catcode `\%=14
  3037. \catcode 43=12
  3038. \catcode`\"=12
  3039. \catcode`\==12
  3040. \catcode`\|=12
  3041. \catcode`\<=12
  3042. \catcode`\>=12
  3043. \escapechar=`\\
  3044. %
  3045. \let\~=\ptextilde
  3046. \let\{=\ptexlbrace
  3047. \let\}=\ptexrbrace
  3048. \let\.=\ptexdot
  3049. \let\*=\ptexstar
  3050. \let\dots=\ptexdots
  3051. \def\@{@}%
  3052. \let\bullet=\ptexbullet
  3053. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  3054. \let\L=\ptexL
  3055. %
  3056. \let\Etex=\endgroup}
  3057.  
  3058. % Define @lisp ... @endlisp.
  3059. % @lisp does a \begingroup so it can rebind things,
  3060. % including the definition of @endlisp (which normally is erroneous).
  3061.  
  3062. % Amount to narrow the margins by for @lisp.
  3063. \newskip\lispnarrowing \lispnarrowing=0.4in
  3064.  
  3065. % This is the definition that ^^M gets inside @lisp, @example, and other
  3066. % such environments.  \null is better than a space, since it doesn't
  3067. % have any width.
  3068. \def\lisppar{\null\endgraf}
  3069.  
  3070. % Make each space character in the input produce a normal interword
  3071. % space in the output.  Don't allow a line break at this space, as this
  3072. % is used only in environments like @example, where each line of input
  3073. % should produce a line of output anyway.
  3074. %
  3075. {\obeyspaces %
  3076. \gdef\sepspaces{\obeyspaces\let =\tie}}
  3077.  
  3078. % Define \obeyedspace to be our active space, whatever it is.  This is
  3079. % for use in \parsearg.
  3080. {\sepspaces%
  3081. \global\let\obeyedspace= }
  3082.  
  3083. % This space is always present above and below environments.
  3084. \newskip\envskipamount \envskipamount = 0pt
  3085.  
  3086. % Make spacing and below environment symmetrical.  We use \parskip here
  3087. % to help in doing that, since in @example-like environments \parskip
  3088. % is reset to zero; thus the \afterenvbreak inserts no space -- but the
  3089. % start of the next paragraph will insert \parskip
  3090. %
  3091. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  3092. \endgraf \ifdim\lastskip<\envskipamount
  3093. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  3094.  
  3095. \let\afterenvbreak = \aboveenvbreak
  3096.  
  3097. % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
  3098. \let\nonarrowing=\relax
  3099.  
  3100. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3101. % \cartouche: draw rectangle w/rounded corners around argument
  3102. \font\circle=lcircle10
  3103. \newdimen\circthick
  3104. \newdimen\cartouter\newdimen\cartinner
  3105. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  3106. \circthick=\fontdimen8\circle
  3107. %
  3108. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  3109. \def\ctr{{\hskip 6pt\circle\char'010}}
  3110. \def\cbl{{\circle\char'012\hskip -6pt}}
  3111. \def\cbr{{\hskip 6pt\circle\char'011}}
  3112. \def\carttop{\hbox to \cartouter{\hskip\lskip
  3113.     \ctl\leaders\hrule height\circthick\hfil\ctr
  3114.     \hskip\rskip}}
  3115. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  3116.     \cbl\leaders\hrule height\circthick\hfil\cbr
  3117.     \hskip\rskip}}
  3118. %
  3119. \newskip\lskip\newskip\rskip
  3120.  
  3121. \long\def\cartouche{%
  3122. \begingroup
  3123.     \lskip=\leftskip \rskip=\rightskip
  3124.     \leftskip=0pt\rightskip=0pt %we want these *outside*.
  3125.     \cartinner=\hsize \advance\cartinner by-\lskip
  3126.                \advance\cartinner by-\rskip
  3127.     \cartouter=\hsize
  3128.     \advance\cartouter by 18pt % allow for 3pt kerns on either
  3129. %                     side, and for 6pt waste from
  3130. %                     each corner char
  3131.     \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  3132.     % Flag to tell @lisp, etc., not to narrow margin.
  3133.     \let\nonarrowing=\comment
  3134.     \vbox\bgroup
  3135.         \baselineskip=0pt\parskip=0pt\lineskip=0pt
  3136.         \carttop
  3137.         \hbox\bgroup
  3138.             \hskip\lskip
  3139.             \vrule\kern3pt
  3140.             \vbox\bgroup
  3141.                 \hsize=\cartinner
  3142.                 \kern3pt
  3143.                 \begingroup
  3144.                     \baselineskip=\normbskip
  3145.                     \lineskip=\normlskip
  3146.                     \parskip=\normpskip
  3147.                     \vskip -\parskip
  3148. \def\Ecartouche{%
  3149.                 \endgroup
  3150.                 \kern3pt
  3151.             \egroup
  3152.             \kern3pt\vrule
  3153.             \hskip\rskip
  3154.         \egroup
  3155.         \cartbot
  3156.     \egroup
  3157. \endgroup
  3158. }}
  3159.  
  3160.  
  3161. % This macro is called at the beginning of all the @example variants,
  3162. % inside a group.
  3163. \def\nonfillstart{%
  3164.   \aboveenvbreak
  3165.   \inENV % This group ends at the end of the body
  3166.   \hfuzz = 12pt % Don't be fussy
  3167.   \sepspaces % Make spaces be word-separators rather than space tokens.
  3168.   \singlespace
  3169.   \let\par = \lisppar % don't ignore blank lines
  3170.   \obeylines % each line of input is a line of output
  3171.   \parskip = 0pt
  3172.   \parindent = 0pt
  3173.   \emergencystretch = 0pt % don't try to avoid overfull boxes
  3174.   % @cartouche defines \nonarrowing to inhibit narrowing
  3175.   % at next level down.
  3176.   \ifx\nonarrowing\relax
  3177.     \advance \leftskip by \lispnarrowing
  3178.     \exdentamount=\lispnarrowing
  3179.     \let\exdent=\nofillexdent
  3180.     \let\nonarrowing=\relax
  3181.   \fi
  3182. }
  3183.  
  3184. % To ending an @example-like environment, we first end the paragraph
  3185. % (via \afterenvbreak's vertical glue), and then the group.  That way we
  3186. % keep the zero \parskip that the environments set -- \parskip glue
  3187. % will be inserted at the beginning of the next paragraph in the
  3188. % document, after the environment.
  3189. %
  3190. \def\nonfillfinish{\afterenvbreak\endgroup}%
  3191.  
  3192. % This macro is
  3193. \def\lisp{\begingroup
  3194.   \nonfillstart
  3195.   \let\Elisp = \nonfillfinish
  3196.   \tt
  3197.   \rawbackslash % have \ input char produce \ char from current font
  3198.   \gobble
  3199. }
  3200.  
  3201. % Define the \E... control sequence only if we are inside the
  3202. % environment, so the error checking in \end will work.
  3203. %
  3204. % We must call \lisp last in the definition, since it reads the
  3205. % return following the @example (or whatever) command.
  3206. %
  3207. \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
  3208. \def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp}
  3209. \def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
  3210.  
  3211. % @smallexample and @smalllisp.  This is not used unless the @smallbook
  3212. % command is given.  Originally contributed by Pavel@xerox.
  3213. %
  3214. \def\smalllispx{\begingroup
  3215.   \nonfillstart
  3216.   \let\Esmalllisp = \nonfillfinish
  3217.   \let\Esmallexample = \nonfillfinish
  3218.   %
  3219.   % Smaller interline space and fonts for small examples.
  3220.   \setleading{10pt}%
  3221.   \indexfonts \tt
  3222.   \rawbackslash % make \ output the \ character from the current font (tt)
  3223.   \gobble
  3224. }
  3225.  
  3226. % This is @display; same as @lisp except use roman font.
  3227. %
  3228. \def\display{\begingroup
  3229.   \nonfillstart
  3230.   \let\Edisplay = \nonfillfinish
  3231.   \gobble
  3232. }
  3233.  
  3234. % This is @format; same as @display except don't narrow margins.
  3235. %
  3236. \def\format{\begingroup
  3237.   \let\nonarrowing = t
  3238.   \nonfillstart
  3239.   \let\Eformat = \nonfillfinish
  3240.   \gobble
  3241. }
  3242.  
  3243. % @flushleft (same as @format) and @flushright.
  3244. %
  3245. \def\flushleft{\begingroup
  3246.   \let\nonarrowing = t
  3247.   \nonfillstart
  3248.   \let\Eflushleft = \nonfillfinish
  3249.   \gobble
  3250. }
  3251. \def\flushright{\begingroup
  3252.   \let\nonarrowing = t
  3253.   \nonfillstart
  3254.   \let\Eflushright = \nonfillfinish
  3255.   \advance\leftskip by 0pt plus 1fill
  3256.   \gobble}
  3257.  
  3258. % @quotation does normal linebreaking (hence we can't use \nonfillstart)
  3259. % and narrows the margins.
  3260. %
  3261. \def\quotation{%
  3262.   \begingroup\inENV %This group ends at the end of the @quotation body
  3263.   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
  3264.   \singlespace
  3265.   \parindent=0pt
  3266.   % We have retained a nonzero parskip for the environment, since we're
  3267.   % doing normal filling. So to avoid extra space below the environment...
  3268.   \def\Equotation{\parskip = 0pt \nonfillfinish}%
  3269.   %
  3270.   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
  3271.   \ifx\nonarrowing\relax
  3272.     \advance\leftskip by \lispnarrowing
  3273.     \advance\rightskip by \lispnarrowing
  3274.     \exdentamount = \lispnarrowing
  3275.     \let\nonarrowing = \relax
  3276.   \fi
  3277. }
  3278.  
  3279. \message{defuns,}
  3280. % Define formatter for defuns
  3281. % First, allow user to change definition object font (\df) internally
  3282. \def\setdeffont #1 {\csname DEF#1\endcsname}
  3283.  
  3284. \newskip\defbodyindent \defbodyindent=.4in
  3285. \newskip\defargsindent \defargsindent=50pt
  3286. \newskip\deftypemargin \deftypemargin=12pt
  3287. \newskip\deflastargmargin \deflastargmargin=18pt
  3288.  
  3289. \newcount\parencount
  3290. % define \functionparens, which makes ( and ) and & do special things.
  3291. % \functionparens affects the group it is contained in.
  3292. \def\activeparens{%
  3293. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  3294. \catcode`\[=\active \catcode`\]=\active}
  3295.  
  3296. % Make control sequences which act like normal parenthesis chars.
  3297. \let\lparen = ( \let\rparen = )
  3298.  
  3299. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  3300.  
  3301. % Be sure that we always have a definition for `(', etc.  For example,
  3302. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  3303. % so TeX would otherwise complain about undefined control sequence.
  3304. \global\let(=\lparen \global\let)=\rparen
  3305. \global\let[=\lbrack \global\let]=\rbrack
  3306.  
  3307. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  3308. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  3309.  
  3310. % Definitions of (, ) and & used in args for functions.
  3311. % This is the definition of ( outside of all parentheses.
  3312. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  3313. \global\advance\parencount by 1 }
  3314. %
  3315. % This is the definition of ( when already inside a level of parens.
  3316. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  3317. %
  3318. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  3319. % also in that case restore the outer-level definition of (.
  3320. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  3321. \global\advance \parencount by -1 }
  3322. % If we encounter &foo, then turn on ()-hacking afterwards
  3323. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  3324. %
  3325. \gdef\normalparens{\boldbrax\let&=\ampnr}
  3326. } % End of definition inside \activeparens
  3327. %% These parens (in \boldbrax) actually are a little bolder than the
  3328. %% contained text.  This is especially needed for [ and ]
  3329. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  3330. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  3331.  
  3332. % First, defname, which formats the header line itself.
  3333. % #1 should be the function name.
  3334. % #2 should be the type of definition, such as "Function".
  3335.  
  3336. \def\defname #1#2{%
  3337. % Get the values of \leftskip and \rightskip as they were
  3338. % outside the @def...
  3339. \dimen2=\leftskip
  3340. \advance\dimen2 by -\defbodyindent
  3341. \dimen3=\rightskip
  3342. \advance\dimen3 by -\defbodyindent
  3343. \noindent        %
  3344. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  3345. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  3346. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  3347. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  3348. % Now output arg 2 ("Function" or some such)
  3349. % ending at \deftypemargin from the right margin,
  3350. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  3351. {% Adjust \hsize to exclude the ambient margins,
  3352. % so that \rightline will obey them.
  3353. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
  3354. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
  3355. % Make all lines underfull and no complaints:
  3356. \tolerance=10000 \hbadness=10000
  3357. \advance\leftskip by -\defbodyindent
  3358. \exdentamount=\defbodyindent
  3359. {\df #1}\enskip        % Generate function name
  3360. }
  3361.  
  3362. % Actually process the body of a definition
  3363. % #1 should be the terminating control sequence, such as \Edefun.
  3364. % #2 should be the "another name" control sequence, such as \defunx.
  3365. % #3 should be the control sequence that actually processes the header,
  3366. %    such as \defunheader.
  3367.  
  3368. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  3369. \medbreak %
  3370. % Define the end token that this defining construct specifies
  3371. % so that it will exit this group.
  3372. \def#1{\endgraf\endgroup\medbreak}%
  3373. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  3374. \parindent=0in
  3375. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  3376. \exdentamount=\defbodyindent
  3377. \begingroup %
  3378. \catcode 61=\active % 61 is `='
  3379. \obeylines\activeparens\spacesplit#3}
  3380.  
  3381. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  3382. \medbreak %
  3383. % Define the end token that this defining construct specifies
  3384. % so that it will exit this group.
  3385. \def#1{\endgraf\endgroup\medbreak}%
  3386. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  3387. \parindent=0in
  3388. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  3389. \exdentamount=\defbodyindent
  3390. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  3391.  
  3392. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  3393. \medbreak %
  3394. % Define the end token that this defining construct specifies
  3395. % so that it will exit this group.
  3396. \def#1{\endgraf\endgroup\medbreak}%
  3397. \def#2##1 ##2 {\def#4{##1}%
  3398. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  3399. \parindent=0in
  3400. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  3401. \exdentamount=\defbodyindent
  3402. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  3403.  
  3404. % These parsing functions are similar to the preceding ones
  3405. % except that they do not make parens into active characters.
  3406. % These are used for "variables" since they have no arguments.
  3407.  
  3408. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  3409. \medbreak %
  3410. % Define the end token that this defining construct specifies
  3411. % so that it will exit this group.
  3412. \def#1{\endgraf\endgroup\medbreak}%
  3413. \def#2{\begingroup\obeylines\spacesplit#3}%
  3414. \parindent=0in
  3415. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  3416. \exdentamount=\defbodyindent
  3417. \begingroup %
  3418. \catcode 61=\active %
  3419. \obeylines\spacesplit#3}
  3420.  
  3421. % This is used for \def{tp,vr}parsebody.  It could probably be used for
  3422. % some of the others, too, with some judicious conditionals.
  3423. \def\parsebodycommon#1#2#3{%
  3424.   \begingroup\inENV %
  3425.   \medbreak %
  3426.   % Define the end token that this defining construct specifies
  3427.   % so that it will exit this group.
  3428.   \def#1{\endgraf\endgroup\medbreak}%
  3429.   \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  3430.   \parindent=0in
  3431.   \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  3432.   \exdentamount=\defbodyindent
  3433.   \begingroup\obeylines
  3434. }
  3435.  
  3436. \def\defvrparsebody#1#2#3#4 {%
  3437.   \parsebodycommon{#1}{#2}{#3}%
  3438.   \spacesplit{#3{#4}}%
  3439. }
  3440.  
  3441. % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
  3442. % type is just `struct', because we lose the braces in `{struct
  3443. % termios}' when \spacesplit reads its undelimited argument.  Sigh.
  3444. % \let\deftpparsebody=\defvrparsebody
  3445. %
  3446. % So, to get around this, we put \empty in with the type name.  That
  3447. % way, TeX won't find exactly `{...}' as an undelimited argument, and
  3448. % won't strip off the braces.
  3449. %
  3450. \def\deftpparsebody #1#2#3#4 {%
  3451.   \parsebodycommon{#1}{#2}{#3}%
  3452.   \spacesplit{\parsetpheaderline{#3{#4}}}\empty
  3453. }
  3454.  
  3455. % Fine, but then we have to eventually remove the \empty *and* the
  3456. % braces (if any).  That's what this does, putting the result in \tptemp.
  3457. \def\removeemptybraces\empty#1\relax{\def\tptemp{#1}}%
  3458.  
  3459. % After \spacesplit has done its work, this is called -- #1 is the final
  3460. % thing to call, #2 the type name (which starts with \empty), and #3
  3461. % (which might be empty) the arguments.
  3462. \def\parsetpheaderline#1#2#3{%
  3463.   \removeemptybraces#2\relax
  3464.   #1{\tptemp}{#3}%
  3465. }%
  3466.  
  3467. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  3468. \medbreak %
  3469. % Define the end token that this defining construct specifies
  3470. % so that it will exit this group.
  3471. \def#1{\endgraf\endgroup\medbreak}%
  3472. \def#2##1 ##2 {\def#4{##1}%
  3473. \begingroup\obeylines\spacesplit{#3{##2}}}%
  3474. \parindent=0in
  3475. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  3476. \exdentamount=\defbodyindent
  3477. \begingroup\obeylines\spacesplit{#3{#5}}}
  3478.  
  3479. % Split up #2 at the first space token.
  3480. % call #1 with two arguments:
  3481. %  the first is all of #2 before the space token,
  3482. %  the second is all of #2 after that space token.
  3483. % If #2 contains no space token, all of it is passed as the first arg
  3484. % and the second is passed as empty.
  3485.  
  3486. {\obeylines
  3487. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  3488. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  3489. \ifx\relax #3%
  3490. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  3491.  
  3492. % So much for the things common to all kinds of definitions.
  3493.  
  3494. % Define @defun.
  3495.  
  3496. % First, define the processing that is wanted for arguments of \defun
  3497. % Use this to expand the args and terminate the paragraph they make up
  3498.  
  3499. \def\defunargs #1{\functionparens \sl
  3500. % Expand, preventing hyphenation at `-' chars.
  3501. % Note that groups don't affect changes in \hyphenchar.
  3502. \hyphenchar\tensl=0
  3503. #1%
  3504. \hyphenchar\tensl=45
  3505. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  3506. \interlinepenalty=10000
  3507. \advance\rightskip by 0pt plus 1fil
  3508. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  3509. }
  3510.  
  3511. \def\deftypefunargs #1{%
  3512. % Expand, preventing hyphenation at `-' chars.
  3513. % Note that groups don't affect changes in \hyphenchar.
  3514. \functionparens
  3515. \tclose{#1}% avoid \code because of side effects on active chars
  3516. \interlinepenalty=10000
  3517. \advance\rightskip by 0pt plus 1fil
  3518. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  3519. }
  3520.  
  3521. % Do complete processing of one @defun or @defunx line already parsed.
  3522.  
  3523. % @deffn Command forward-char nchars
  3524.  
  3525. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  3526.  
  3527. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  3528. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  3529. \catcode 61=\other % Turn off change made in \defparsebody
  3530. }
  3531.  
  3532. % @defun == @deffn Function
  3533.  
  3534. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  3535.  
  3536. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  3537. \begingroup\defname {#1}{Function}%
  3538. \defunargs {#2}\endgroup %
  3539. \catcode 61=\other % Turn off change made in \defparsebody
  3540. }
  3541.  
  3542. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  3543.  
  3544. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  3545.  
  3546. % #1 is the data type.  #2 is the name and args.
  3547. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  3548. % #1 is the data type, #2 the name, #3 the args.
  3549. \def\deftypefunheaderx #1#2 #3\relax{%
  3550. \doind {fn}{\code{#2}}% Make entry in function index
  3551. \begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}%
  3552. \deftypefunargs {#3}\endgroup %
  3553. \catcode 61=\other % Turn off change made in \defparsebody
  3554. }
  3555.  
  3556. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  3557.  
  3558. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  3559.  
  3560. % \defheaderxcond#1\relax$$$
  3561. % puts #1 in @code, followed by a space, but does nothing if #1 is null.
  3562. \def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi}
  3563.  
  3564. % #1 is the classification.  #2 is the data type.  #3 is the name and args.
  3565. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  3566. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  3567. \def\deftypefnheaderx #1#2#3 #4\relax{%
  3568. \doind {fn}{\code{#3}}% Make entry in function index
  3569. \begingroup
  3570. \normalparens % notably, turn off `&' magic, which prevents
  3571. %               at least some C++ text from working
  3572. \defname {\defheaderxcond#2\relax$$$#3}{#1}%
  3573. \deftypefunargs {#4}\endgroup %
  3574. \catcode 61=\other % Turn off change made in \defparsebody
  3575. }
  3576.  
  3577. % @defmac == @deffn Macro
  3578.  
  3579. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  3580.  
  3581. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  3582. \begingroup\defname {#1}{Macro}%
  3583. \defunargs {#2}\endgroup %
  3584. \catcode 61=\other % Turn off change made in \defparsebody
  3585. }
  3586.  
  3587. % @defspec == @deffn Special Form
  3588.  
  3589. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  3590.  
  3591. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  3592. \begingroup\defname {#1}{Special Form}%
  3593. \defunargs {#2}\endgroup %
  3594. \catcode 61=\other % Turn off change made in \defparsebody
  3595. }
  3596.  
  3597. % This definition is run if you use @defunx
  3598. % anywhere other than immediately after a @defun or @defunx.
  3599.  
  3600. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  3601. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  3602. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  3603. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  3604. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  3605. \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
  3606.  
  3607. % @defmethod, and so on
  3608.  
  3609. % @defop {Funny Method} foo-class frobnicate argument
  3610.  
  3611. \def\defop #1 {\def\defoptype{#1}%
  3612. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  3613.  
  3614. \def\defopheader #1#2#3{%
  3615. \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  3616. \begingroup\defname {#2}{\defoptype{} on #1}%
  3617. \defunargs {#3}\endgroup %
  3618. }
  3619.  
  3620. % @defmethod == @defop Method
  3621.  
  3622. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  3623.  
  3624. \def\defmethodheader #1#2#3{%
  3625. \dosubind {fn}{\code{#2}}{on #1}% entry in function index
  3626. \begingroup\defname {#2}{Method on #1}%
  3627. \defunargs {#3}\endgroup %
  3628. }
  3629.  
  3630. % @defcv {Class Option} foo-class foo-flag
  3631.  
  3632. \def\defcv #1 {\def\defcvtype{#1}%
  3633. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  3634.  
  3635. \def\defcvarheader #1#2#3{%
  3636. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  3637. \begingroup\defname {#2}{\defcvtype{} of #1}%
  3638. \defvarargs {#3}\endgroup %
  3639. }
  3640.  
  3641. % @defivar == @defcv {Instance Variable}
  3642.  
  3643. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  3644.  
  3645. \def\defivarheader #1#2#3{%
  3646. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  3647. \begingroup\defname {#2}{Instance Variable of #1}%
  3648. \defvarargs {#3}\endgroup %
  3649. }
  3650.  
  3651. % These definitions are run if you use @defmethodx, etc.,
  3652. % anywhere other than immediately after a @defmethod, etc.
  3653.  
  3654. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  3655. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  3656. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  3657. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  3658.  
  3659. % Now @defvar
  3660.  
  3661. % First, define the processing that is wanted for arguments of @defvar.
  3662. % This is actually simple: just print them in roman.
  3663. % This must expand the args and terminate the paragraph they make up
  3664. \def\defvarargs #1{\normalparens #1%
  3665. \interlinepenalty=10000
  3666. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  3667.  
  3668. % @defvr Counter foo-count
  3669.  
  3670. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  3671.  
  3672. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  3673. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  3674.  
  3675. % @defvar == @defvr Variable
  3676.  
  3677. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  3678.  
  3679. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  3680. \begingroup\defname {#1}{Variable}%
  3681. \defvarargs {#2}\endgroup %
  3682. }
  3683.  
  3684. % @defopt == @defvr {User Option}
  3685.  
  3686. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  3687.  
  3688. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  3689. \begingroup\defname {#1}{User Option}%
  3690. \defvarargs {#2}\endgroup %
  3691. }
  3692.  
  3693. % @deftypevar int foobar
  3694.  
  3695. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  3696.  
  3697. % #1 is the data type.  #2 is the name.
  3698. \def\deftypevarheader #1#2{%
  3699. \doind {vr}{\code{#2}}% Make entry in variables index
  3700. \begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}%
  3701. \interlinepenalty=10000
  3702. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  3703. \endgroup}
  3704.  
  3705. % @deftypevr {Global Flag} int enable
  3706.  
  3707. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  3708.  
  3709. \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
  3710. \begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1}
  3711. \interlinepenalty=10000
  3712. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  3713. \endgroup}
  3714.  
  3715. % This definition is run if you use @defvarx
  3716. % anywhere other than immediately after a @defvar or @defvarx.
  3717.  
  3718. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  3719. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  3720. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  3721. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  3722. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  3723.  
  3724. % Now define @deftp
  3725. % Args are printed in bold, a slight difference from @defvar.
  3726.  
  3727. \def\deftpargs #1{\bf \defvarargs{#1}}
  3728.  
  3729. % @deftp Class window height width ...
  3730.  
  3731. \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
  3732.  
  3733. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  3734. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  3735.  
  3736. % This definition is run if you use @deftpx, etc
  3737. % anywhere other than immediately after a @deftp, etc.
  3738.  
  3739. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  3740.  
  3741. \message{cross reference,}
  3742. % Define cross-reference macros
  3743. \newwrite \auxfile
  3744.  
  3745. \newif\ifhavexrefs  % True if xref values are known.
  3746. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  3747.  
  3748. % \setref{foo} defines a cross-reference point named foo.
  3749.  
  3750. \def\setref#1{%
  3751. \dosetq{#1-title}{Ytitle}%
  3752. \dosetq{#1-pg}{Ypagenumber}%
  3753. \dosetq{#1-snt}{Ysectionnumberandtype}}
  3754.  
  3755. \def\unnumbsetref#1{%
  3756. \dosetq{#1-title}{Ytitle}%
  3757. \dosetq{#1-pg}{Ypagenumber}%
  3758. \dosetq{#1-snt}{Ynothing}}
  3759.  
  3760. \def\appendixsetref#1{%
  3761. \dosetq{#1-title}{Ytitle}%
  3762. \dosetq{#1-pg}{Ypagenumber}%
  3763. \dosetq{#1-snt}{Yappendixletterandtype}}
  3764.  
  3765. % \xref, \pxref, and \ref generate cross-references to specified points.
  3766. % For \xrefX, #1 is the node name, #2 the name of the Info
  3767. % cross-reference, #3 the printed node name, #4 the name of the Info
  3768. % file, #5 the name of the printed manual.  All but the node name can be
  3769. % omitted.
  3770. %
  3771. \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
  3772. \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
  3773. \def\ref#1{\xrefX[#1,,,,,,,]}
  3774. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
  3775.   \def\printedmanual{\ignorespaces #5}%
  3776.   \def\printednodename{\ignorespaces #3}%
  3777.   \setbox1=\hbox{\printedmanual}%
  3778.   \setbox0=\hbox{\printednodename}%
  3779.   \ifdim \wd0 = 0pt
  3780.     % No printed node name was explicitly given.
  3781.     \ifx\SETxref-automatic-section-title\relax %
  3782.       % Use the actual chapter/section title appear inside
  3783.       % the square brackets.  Use the real section title if we have it.
  3784.       \ifdim \wd1>0pt%
  3785.         % It is in another manual, so we don't have it.
  3786.         \def\printednodename{\ignorespaces #1}%
  3787.       \else
  3788.         \ifhavexrefs
  3789.           % We know the real title if we have the xref values.
  3790.           \def\printednodename{\refx{#1-title}}%
  3791.         \else
  3792.           % Otherwise just copy the Info node name.
  3793.           \def\printednodename{\ignorespaces #1}%
  3794.         \fi%
  3795.       \fi
  3796.       \def\printednodename{#1-title}%
  3797.     \else
  3798.       % Use the node name inside the square brackets.
  3799.       \def\printednodename{\ignorespaces #1}%
  3800.     \fi
  3801.   \fi
  3802.   %
  3803.   % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
  3804.   % insert empty discretionaries after hyphens, which means that it will
  3805.   % not find a line break at a hyphen in a node names.  Since some manuals
  3806.   % are best written with fairly long node names, containing hyphens, this
  3807.   % is a loss.  Therefore, we give the text of the node name again, so it
  3808.   % is as if TeX is seeing it for the first time.
  3809.   \ifdim \wd1 > 0pt
  3810.     \putwordsection{} ``\printednodename'' in \cite{\printedmanual}%
  3811.   \else
  3812.     % _ (for example) has to be the character _ for the purposes of the
  3813.     % control sequence corresponding to the node, but it has to expand
  3814.     % into the usual \leavevmode...\vrule stuff for purposes of
  3815.     % printing. So we \turnoffactive for the \refx-snt, back on for the
  3816.     % printing, back off for the \refx-pg.
  3817.     {\turnoffactive \refx{#1-snt}{}}%
  3818.     \space [\printednodename],\space
  3819.     \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
  3820.   \fi
  3821. \endgroup}
  3822.  
  3823. % \dosetq is the interface for calls from other macros
  3824.  
  3825. % Use \turnoffactive so that punctuation chars such as underscore
  3826. % work in node names.
  3827. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  3828. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  3829. \next}}
  3830.  
  3831. % \internalsetq {foo}{page} expands into
  3832. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  3833. % When the aux file is read, ' is the escape character
  3834.  
  3835. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  3836.  
  3837. % Things to be expanded by \internalsetq
  3838.  
  3839. \def\Ypagenumber{\folio}
  3840.  
  3841. \def\Ytitle{\thissection}
  3842.  
  3843. \def\Ynothing{}
  3844.  
  3845. \def\Ysectionnumberandtype{%
  3846. \ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
  3847. \else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
  3848. \else \ifnum \subsubsecno=0 %
  3849. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
  3850. \else %
  3851. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  3852. \fi \fi \fi }
  3853.  
  3854. \def\Yappendixletterandtype{%
  3855. \ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
  3856. \else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
  3857. \else \ifnum \subsubsecno=0 %
  3858. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  3859. \else %
  3860. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  3861. \fi \fi \fi }
  3862.  
  3863. \gdef\xreftie{'tie}
  3864.  
  3865. % Use TeX 3.0's \inputlineno to get the line number, for better error
  3866. % messages, but if we're using an old version of TeX, don't do anything.
  3867. %
  3868. \ifx\inputlineno\thisisundefined
  3869.   \let\linenumber = \empty % Non-3.0.
  3870. \else
  3871.   \def\linenumber{\the\inputlineno:\space}
  3872. \fi
  3873.  
  3874. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  3875. % If its value is nonempty, SUFFIX is output afterward.
  3876.  
  3877. \def\refx#1#2{%
  3878.   \expandafter\ifx\csname X#1\endcsname\relax
  3879.     % If not defined, say something at least.
  3880.     $\langle$un\-de\-fined$\rangle$%
  3881.     \ifhavexrefs
  3882.       \message{\linenumber Undefined cross reference `#1'.}%
  3883.     \else
  3884.       \ifwarnedxrefs\else
  3885.         \global\warnedxrefstrue
  3886.         \message{Cross reference values unknown; you must run TeX again.}%
  3887.       \fi
  3888.     \fi
  3889.   \else
  3890.     % It's defined, so just use it.
  3891.     \csname X#1\endcsname
  3892.   \fi
  3893.   #2% Output the suffix in any case.
  3894. }
  3895.  
  3896. % Read the last existing aux file, if any.  No error if none exists.
  3897.  
  3898. % This is the macro invoked by entries in the aux file.
  3899. \def\xrdef #1#2{
  3900. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  3901.  
  3902. \def\readauxfile{%
  3903. \begingroup
  3904. \catcode `\^^@=\other
  3905. \catcode `\=\other
  3906. \catcode `\=\other
  3907. \catcode `\^^C=\other
  3908. \catcode `\^^D=\other
  3909. \catcode `\^^E=\other
  3910. \catcode `\^^F=\other
  3911. \catcode `\^^G=\other
  3912. \catcode `\^^H=\other
  3913. \catcode `\ =\other
  3914. \catcode `\^^L=\other
  3915. \catcode `\=\other
  3916. \catcode `\=\other
  3917. \catcode `\=\other
  3918. \catcode `\=\other
  3919. \catcode `\=\other
  3920. \catcode `\=\other
  3921. \catcode `\=\other
  3922. \catcode `\=\other
  3923. \catcode `\=\other
  3924. \catcode `\=\other
  3925. \catcode `\=\other
  3926. \catcode `\=\other
  3927. \catcode 26=\other
  3928. \catcode `\^^[=\other
  3929. \catcode `\^^\=\other
  3930. \catcode `\^^]=\other
  3931. \catcode `\^^^=\other
  3932. \catcode `\^^_=\other
  3933. \catcode `\@=\other
  3934. \catcode `\^=\other
  3935. \catcode `\~=\other
  3936. \catcode `\[=\other
  3937. \catcode `\]=\other
  3938. \catcode`\"=\other
  3939. \catcode`\_=\other
  3940. \catcode`\|=\other
  3941. \catcode`\<=\other
  3942. \catcode`\>=\other
  3943. \catcode `\$=\other
  3944. \catcode `\#=\other
  3945. \catcode `\&=\other
  3946. % `\+ does not work, so use 43.
  3947. \catcode 43=\other
  3948. % Make the characters 128-255 be printing characters
  3949. {%
  3950.   \count 1=128
  3951.   \def\loop{%
  3952.     \catcode\count 1=\other
  3953.     \advance\count 1 by 1
  3954.     \ifnum \count 1<256 \loop \fi
  3955.   }%
  3956. }%
  3957. % the aux file uses ' as the escape.
  3958. % Turn off \ as an escape so we do not lose on
  3959. % entries which were dumped with control sequences in their names.
  3960. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  3961. % Reference to such entries still does not work the way one would wish,
  3962. % but at least they do not bomb out when the aux file is read in.
  3963. \catcode `\{=1 \catcode `\}=2
  3964. \catcode `\%=\other
  3965. \catcode `\'=0
  3966. \catcode `\\=\other
  3967. \openin 1 \jobname.aux
  3968. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  3969. \global\warnedobstrue
  3970. \fi
  3971. % Open the new aux file.  Tex will close it automatically at exit.
  3972. \openout \auxfile=\jobname.aux
  3973. \endgroup}
  3974.  
  3975.  
  3976. % Footnotes.
  3977.  
  3978. \newcount \footnoteno
  3979.  
  3980. % The trailing space in the following definition for supereject is
  3981. % vital for proper filling; pages come out unaligned when you do a
  3982. % pagealignmacro call if that space before the closing brace is
  3983. % removed.
  3984. \def\supereject{\par\penalty -20000\footnoteno =0 }
  3985.  
  3986. % @footnotestyle is meaningful for info output only..
  3987. \let\footnotestyle=\comment
  3988.  
  3989. \let\ptexfootnote=\footnote
  3990.  
  3991. {\catcode `\@=11
  3992. %
  3993. % Auto-number footnotes.  Otherwise like plain.
  3994. \gdef\footnote{%
  3995.   \global\advance\footnoteno by \@ne
  3996.   \edef\thisfootno{$^{\the\footnoteno}$}%
  3997.   %
  3998.   % In case the footnote comes at the end of a sentence, preserve the
  3999.   % extra spacing after we do the footnote number.
  4000.   \let\@sf\empty
  4001.   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  4002.   %
  4003.   % Remove inadvertent blank space before typesetting the footnote number.
  4004.   \unskip
  4005.   \thisfootno\@sf
  4006.   \footnotezzz
  4007. }%
  4008.  
  4009. % Don't bother with the trickery in plain.tex to not require the
  4010. % footnote text as a parameter.  Our footnotes don't need to be so general.
  4011. %
  4012. \long\gdef\footnotezzz#1{\insert\footins{%
  4013.   % We want to typeset this text as a normal paragraph, even if the
  4014.   % footnote reference occurs in (for example) a display environment.
  4015.   % So reset some parameters.
  4016.   \interlinepenalty\interfootnotelinepenalty
  4017.   \splittopskip\ht\strutbox % top baseline for broken footnotes
  4018.   \splitmaxdepth\dp\strutbox
  4019.   \floatingpenalty\@MM
  4020.   \leftskip\z@skip
  4021.   \rightskip\z@skip
  4022.   \spaceskip\z@skip
  4023.   \xspaceskip\z@skip
  4024.   \parindent\defaultparindent
  4025.   %
  4026.   % Hang the footnote text off the number.
  4027.   \hang
  4028.   \textindent{\thisfootno}%
  4029.   %
  4030.   % Don't crash into the line above the footnote text.  Since this
  4031.   % expands into a box, it must come within the paragraph, lest it
  4032.   % provide a place where TeX can split the footnote.
  4033.   \footstrut
  4034.   #1\strut}%
  4035. }
  4036.  
  4037. }%end \catcode `\@=11
  4038.  
  4039. % Set the baselineskip to #1, and the lineskip and strut size
  4040. % correspondingly.  There is no deep meaning behind these magic numbers
  4041. % used as factors; they just match (closely enough) what Knuth defined.
  4042. %
  4043. \def\lineskipfactor{.08333}
  4044. \def\strutheightpercent{.70833}
  4045. \def\strutdepthpercent {.29167}
  4046. %
  4047. \def\setleading#1{%
  4048.   \normalbaselineskip = #1\relax
  4049.   \normallineskip = \lineskipfactor\normalbaselineskip
  4050.   \normalbaselines
  4051.   \setbox\strutbox =\hbox{%
  4052.     \vrule width0pt height\strutheightpercent\baselineskip
  4053.                     depth \strutdepthpercent \baselineskip
  4054.   }%
  4055. }
  4056.  
  4057. % @| inserts a changebar to the left of the current line.  It should
  4058. % surround any changed text.  This approach does *not* work if the
  4059. % change spans more than two lines of output.  To handle that, we would
  4060. % have adopt a much more difficult approach (putting marks into the main
  4061. % vertical list for the beginning and end of each change).
  4062. %
  4063. \def\|{%
  4064.   % \vadjust can only be used in horizontal mode.
  4065.   \leavevmode
  4066.   %
  4067.   % Append this vertical mode material after the current line in the output.
  4068.   \vadjust{%
  4069.     % We want to insert a rule with the height and depth of the current
  4070.     % leading; that is exactly what \strutbox is supposed to record.
  4071.     \vskip-\baselineskip
  4072.     %
  4073.     % \vadjust-items are inserted at the left edge of the type.  So
  4074.     % the \llap here moves out into the left-hand margin.
  4075.     \llap{%
  4076.       %
  4077.       % For a thicker or thinner bar, change the `1pt'.
  4078.       \vrule height\baselineskip width1pt
  4079.       %
  4080.       % This is the space between the bar and the text.
  4081.       \hskip 12pt
  4082.     }%
  4083.   }%
  4084. }
  4085.  
  4086. % For a final copy, take out the rectangles
  4087. % that mark overfull boxes (in case you have decided
  4088. % that the text looks ok even though it passes the margin).
  4089. %
  4090. \def\finalout{\overfullrule=0pt}
  4091.  
  4092.  
  4093. % End of control word definitions.
  4094.  
  4095. \message{and turning on texinfo input format.}
  4096.  
  4097. \def\openindices{%
  4098.    \newindex{cp}%
  4099.    \newcodeindex{fn}%
  4100.    \newcodeindex{vr}%
  4101.    \newcodeindex{tp}%
  4102.    \newcodeindex{ky}%
  4103.    \newcodeindex{pg}%
  4104. }
  4105.  
  4106. % Set some numeric style parameters, for 8.5 x 11 format.
  4107.  
  4108. %\hsize = 6.5in
  4109. \newdimen\defaultparindent \defaultparindent = 15pt
  4110. \parindent = \defaultparindent
  4111. \parskip 18pt plus 1pt
  4112. \setleading{15pt}
  4113. \advance\topskip by 1.2cm
  4114.  
  4115. % Prevent underfull vbox error messages.
  4116. \vbadness=10000
  4117.  
  4118. % Following George Bush, just get rid of widows and orphans.
  4119. \widowpenalty=10000
  4120. \clubpenalty=10000
  4121.  
  4122. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  4123. % using an old version of TeX, don't do anything.  We want the amount of
  4124. % stretch added to depend on the line length, hence the dependence on
  4125. % \hsize.  This makes it come to about 9pt for the 8.5x11 format.
  4126. %
  4127. \ifx\emergencystretch\thisisundefined
  4128.   % Allow us to assign to \emergencystretch anyway.
  4129.   \def\emergencystretch{\dimen0}%
  4130. \else
  4131.   \emergencystretch = \hsize
  4132.   \divide\emergencystretch by 45
  4133. \fi
  4134.  
  4135. % Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
  4136. \def\smallbook{
  4137.  
  4138. % These values for secheadingskip and subsecheadingskip are
  4139. % experiments.  RJC 7 Aug 1992
  4140. \global\secheadingskip = 17pt plus 6pt minus 3pt
  4141. \global\subsecheadingskip = 14pt plus 6pt minus 3pt
  4142.  
  4143. \global\lispnarrowing = 0.3in
  4144. \setleading{12pt}
  4145. \advance\topskip by -1cm
  4146. \global\parskip 3pt plus 1pt
  4147. \global\hsize = 5in
  4148. \global\vsize=7.5in
  4149. \global\tolerance=700
  4150. \global\hfuzz=1pt
  4151. \global\contentsrightmargin=0pt
  4152. \global\deftypemargin=0pt
  4153. \global\defbodyindent=.5cm
  4154.  
  4155. \global\pagewidth=\hsize
  4156. \global\pageheight=\vsize
  4157.  
  4158. \global\let\smalllisp=\smalllispx
  4159. \global\let\smallexample=\smalllispx
  4160. \global\def\Esmallexample{\Esmalllisp}
  4161. }
  4162.  
  4163. % Use @afourpaper to print on European A4 paper.
  4164. \def\afourpaper{
  4165. \global\tolerance=700
  4166. \global\hfuzz=1pt
  4167. \setleading{12pt}
  4168. \global\parskip 15pt plus 1pt
  4169.  
  4170. \global\vsize= 53\baselineskip
  4171. \advance\vsize by \topskip
  4172. %\global\hsize=   5.85in     % A4 wide 10pt
  4173. \global\hsize=  6.5in
  4174. \global\outerhsize=\hsize
  4175. \global\advance\outerhsize by 0.5in
  4176. \global\outervsize=\vsize
  4177. \global\advance\outervsize by 0.6in
  4178.  
  4179. \global\pagewidth=\hsize
  4180. \global\pageheight=\vsize
  4181. }
  4182.  
  4183. % Allow control of the text dimensions.  Parameters in order: textheight;
  4184. % textwidth; \voffset; \hoffset (!); binding offset.  All require a dimension;
  4185. % header is additional; added length extends the bottom of the page.
  4186.  
  4187. \def\changepagesizes#1#2#3#4#5
  4188. {\global\vsize= #1
  4189.  \advance\vsize by \topskip
  4190.  \global\voffset= #3
  4191.  \global\hsize= #2
  4192.  \global\outerhsize=\hsize
  4193.  \global\advance\outerhsize by 0.5in
  4194.  \global\outervsize=\vsize
  4195.  \global\advance\outervsize by 0.6in
  4196.  \global\pagewidth=\hsize
  4197.  \global\pageheight=\vsize
  4198.  \global\normaloffset= #4
  4199.  \global\bindingoffset= #5}
  4200.  
  4201. % This layout is compatible with Latex on A4 paper.
  4202.  
  4203. \def\afourlatex{\changepagesizes{22cm}{15cm}{7mm}{4.6mm}{5mm}}
  4204.  
  4205. % Define macros to output various characters with catcode for normal text.
  4206. \catcode`\"=\other
  4207. \catcode`\~=\other
  4208. \catcode`\^=\other
  4209. \catcode`\_=\other
  4210. \catcode`\|=\other
  4211. \catcode`\<=\other
  4212. \catcode`\>=\other
  4213. \catcode`\+=\other
  4214. \def\normaldoublequote{"}
  4215. \def\normaltilde{~}
  4216. \def\normalcaret{^}
  4217. \def\normalunderscore{_}
  4218. \def\normalverticalbar{|}
  4219. \def\normalless{<}
  4220. \def\normalgreater{>}
  4221. \def\normalplus{+}
  4222.  
  4223. % This macro is used to make a character print one way in ttfont
  4224. % where it can probably just be output, and another way in other fonts,
  4225. % where something hairier probably needs to be done.
  4226. %
  4227. % #1 is what to print if we are indeed using \tt; #2 is what to print
  4228. % otherwise.  Since all the Computer Modern typewriter fonts have zero
  4229. % interword stretch (and shrink), and it is reasonable to expect all
  4230. % typewriter fonts to have this, we can check that font parameter.
  4231. %
  4232. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  4233.  
  4234. % Turn off all special characters except @
  4235. % (and those which the user can use as if they were ordinary).
  4236. % Most of these we simply print from the \tt font, but for some, we can
  4237. % use math or other variants that look better in normal text.
  4238.  
  4239. \catcode`\"=\active
  4240. \def\activedoublequote{{\tt \char '042}}
  4241. \let"=\activedoublequote
  4242. \catcode`\~=\active
  4243. \def~{{\tt \char '176}}
  4244. \chardef\hat=`\^
  4245. \catcode`\^=\active
  4246. \def^{{\tt \hat}}
  4247.  
  4248. \catcode`\_=\active
  4249. \def_{\ifusingtt\normalunderscore\_}
  4250. % Subroutine for the previous macro.
  4251. \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  4252.  
  4253. % \lvvmode is equivalent in function to \leavevmode.
  4254. % Using \leavevmode runs into trouble when written out to
  4255. % an index file due to the expansion of \leavevmode into ``\unhbox
  4256. % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
  4257. % magic tricks with @.
  4258. \def\lvvmode{\vbox to 0pt{}}
  4259.  
  4260. \catcode`\|=\active
  4261. \def|{{\tt \char '174}}
  4262. \chardef \less=`\<
  4263. \catcode`\<=\active
  4264. \def<{{\tt \less}}
  4265. \chardef \gtr=`\>
  4266. \catcode`\>=\active
  4267. \def>{{\tt \gtr}}
  4268. \catcode`\+=\active
  4269. \def+{{\tt \char 43}}
  4270. %\catcode 27=\active
  4271. %\def^^[{$\diamondsuit$}
  4272.  
  4273. % Set up an active definition for =, but don't enable it most of the time.
  4274. {\catcode`\==\active
  4275. \global\def={{\tt \char 61}}}
  4276.  
  4277. \catcode`\@=0
  4278.  
  4279. % \rawbackslashxx output one backslash character in current font
  4280. \global\chardef\rawbackslashxx=`\\
  4281. %{\catcode`\\=\other
  4282. %@gdef@rawbackslashxx{\}}
  4283.  
  4284. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  4285. {\catcode`\\=\active
  4286. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  4287.  
  4288. % \normalbackslash outputs one backslash in fixed width font.
  4289. \def\normalbackslash{{\tt\rawbackslashxx}}
  4290.  
  4291. % Say @foo, not \foo, in error messages.
  4292. \escapechar=`\@
  4293.  
  4294. % \catcode 17=0   % Define control-q
  4295. \catcode`\\=\active
  4296.  
  4297. % Used sometimes to turn off (effectively) the active characters
  4298. % even after parsing them.
  4299. @def@turnoffactive{@let"=@normaldoublequote
  4300. @let\=@realbackslash
  4301. @let~=@normaltilde
  4302. @let^=@normalcaret
  4303. @let_=@normalunderscore
  4304. @let|=@normalverticalbar
  4305. @let<=@normalless
  4306. @let>=@normalgreater
  4307. @let+=@normalplus}
  4308.  
  4309. @def@normalturnoffactive{@let"=@normaldoublequote
  4310. @let\=@normalbackslash
  4311. @let~=@normaltilde
  4312. @let^=@normalcaret
  4313. @let_=@normalunderscore
  4314. @let|=@normalverticalbar
  4315. @let<=@normalless
  4316. @let>=@normalgreater
  4317. @let+=@normalplus}
  4318.  
  4319. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  4320. % That is what \eatinput is for; after that, the `\' should revert to printing
  4321. % a backslash.
  4322. %
  4323. @gdef@eatinput input texinfo{@fixbackslash}
  4324. @global@let\ = @eatinput
  4325.  
  4326. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  4327. % the first `\{ in the file would cause an error. This macro tries to fix
  4328. % that, assuming it is called before the first `\' could plausibly occur.
  4329. %
  4330. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  4331.  
  4332. %% These look ok in all fonts, so just make them not special.  The @rm below
  4333. %% makes sure that the current font starts out as the newly loaded cmr10
  4334. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  4335.  
  4336. @textfonts
  4337. @rm
  4338.  
  4339. @c Local variables:
  4340. @c page-delimiter: "^\\\\message"
  4341. @c End:
  4342.